Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Different types of files that acceleo can generate(Acceleo is able to generate all sorts of text files so how can I choose the type of the generated file?)
Different types of files that acceleo can generate [message #1784730] Tue, 03 April 2018 10:22 Go to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Good morning,

I want to generate a .qml file from an Ecore model using acceleo, I'm using Eclipse JUNO, I've succeeded in generating different files .h and .cpp but I couldn't manage to find the "property" that's responsible in determining the generated file type (.cpp/ .js/ .qml or any other type).
So, how can I determine the type (extension) of the generated file?)

Thank u in advance ^^
Re: Different types of files that acceleo can generate [message #1784732 is a reply to message #1784730] Tue, 03 April 2018 10:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

The external file system is not really part of the model transformation. Consequently many of its characteristics are hidden. The 'correct' solution is to pass filenames as additional input parameters if you really need them. Perhaps Acceleo has some helper functions. You could invoke a Java function.

Regards

Ed Willink

Re: Different types of files that acceleo can generate [message #1784734 is a reply to message #1784732] Tue, 03 April 2018 10:58 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
hey,

I don't quite understand what u said, So could you please walk me through the 'correct' way that you mentioned!

Thank u for ur help.
Re: Different types of files that acceleo can generate [message #1784737 is a reply to message #1784734] Tue, 03 April 2018 11:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

Just as with normal functions you can have many arguments, add another if you need one. So in Acceleo I think templates can have manyparameters. Add another one.

I would expect to see it in the launch config, but I don't see parameters there but in the Main java I see

/*
* Add in this list all the arguments used by the starting point of the generation
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
so I guess this is what you follow.

Sorry. my Acceleo knowledge is very rusty. I don't use Accelo any more.

Regards

Ed Willink
Re: Different types of files that acceleo can generate [message #1784744 is a reply to message #1784737] Tue, 03 April 2018 13:12 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

I'll try to do what you said.
Thank u so much for ur help.

Kind regards,
Re: Different types of files that acceleo can generate [message #1784747 is a reply to message #1784744] Tue, 03 April 2018 13:57 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

Another question please, so the java Main that u mentioned! is it a java class/project that I should create within my Acceleo project? or it already exists in my project( even though I cnt find it !)

Kind regards,
Re: Different types of files that acceleo can generate [message #1784756 is a reply to message #1784747] Tue, 03 April 2018 15:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

Acceleo auto-creates a Java class with a main that invokes the Accelo support.

Regards

Ed Willink
Re: Different types of files that acceleo can generate [message #1784782 is a reply to message #1784756] Wed, 04 April 2018 07:41 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Good morning,

So I guess this is the java code, you'll find it below, that I should manipulate in order to get my .qml file ?!

******************************************************************************

/**
* This can be used to launch the generation from a standalone application.
*
* @param args
* Arguments of the generation.
* @generated
*/
public static void main(String[] args) {
try {
if (args.length < 2) {
System.out.println("Arguments not valid : {model, folder}.");
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);

List<String> arguments = new ArrayList<String>();

/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/

/*
* Add in this list all the arguments used by the starting point of the generation
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/

Generate generator = new Generate(modelURI, folder, arguments);

/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
* If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/

for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}

generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
e.printStackTrace();
}
}

****************************************************************************
Re: Different types of files that acceleo can generate [message #1784787 is a reply to message #1784782] Wed, 04 April 2018 07:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

Yes. "This can be used to launch" . You are free to code something different.

Regards

Ed Willink
Re: Different types of files that acceleo can generate [message #1784789 is a reply to message #1784787] Wed, 04 April 2018 07:56 Go to previous message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

Thank u for ur time and effort.

Kind regards,
Previous Topic: unable to install new softwares
Next Topic:Acceleo Code
Goto Forum:
  


Current Time: Sun Sep 23 08:01:34 GMT 2018

Powered by FUDForum. Page generated in 0.04210 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top