Retrieve target folder during generation [message #894755] |
Tue, 10 July 2012 07:49  |
Eclipse User |
|
|
|
Hi all,
is there a way to retrieve the target folder during generation? With target folder I mean the root folder to which all files are generated, configured in the launch configuration.
I would like to use this to provide a warning to the user in case a file is generated to another location, such that he can manually remove it from the old location. Please note that both locations are determined at forehand.
Thanks!
|
|
|
|
|
Re: Retrieve target folder during generation [message #1785253 is a reply to message #896086] |
Wed, 11 April 2018 11:18  |
Eclipse User |
|
|
|
Hello all,
I have solved this one by creating a static field in the Generate.java folder.
I am seting it to the target folder when registering my ecore model.
This is how it is set in Generate.java
* USed to find the name of the target folder so we can copy non mtls.
*
* @generated NOT
*/
public static String currentTargetFolder = "Not Defined Yet";
/**
* This allows clients to instantiates a generator with all required information.
*
* @param modelURI
* URI where the model on which this generator will be used is located.
* @param targetFolder
* This will be used as the output folder for this generation : it will be the base path
* against which all file block URLs will be resolved.
* @param arguments
* If the template which will be called requires more than one argument taken from the model,
* pass them here.
* @throws IOException
* This can be thrown in three scenarios : the module cannot be found, it cannot be loaded, or
* the model cannot be loaded.
* @generated NOT
*/
public GenerateMaziDocs(URI modelURI, File targetFolder,
List<? extends Object> arguments) throws IOException {
MYECOREDSL.doSetup();
initialize(modelURI, targetFolder, arguments);
currentTargetFolder = this.getTargetFolder().getAbsolutePath();
}
This is how i am accessing it in the java wrapper
Generate.currentTargetFolder
Hope it makes sense.
Posting in the case someone can see some side effects or help others
Thanks
Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.03648 seconds