Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3] pass arguments in run configuration
[Acceleo 3] pass arguments in run configuration [message #690615] Wed, 29 June 2011 20:34 Go to next message
the_ch40s is currently offline the_ch40sFriend
Messages: 14
Registered: April 2011
Junior Member
Hello there,
i have a (main)template which expects 2 arguments besides the EObject it generates for.
Before the update that came with Indigo, i could simply add these arguments in the run configuration under "properties" (one argument per line). This does not work with the new version.
I understand the procedure for this has been changed, but i dont understand how this works. Obviously, one argument per line in the "properties files" tab does not work, but when i add the workspace path of a file that contains the arguments, it does not work either.
I know i can pass these arguments by calling the generate() method, but as of now i would like to know how i can achieve what i have done with the previous version Smile

Also, i got an annoying bug:
When starting eclipse and launching my plugin-project (meaning the acceleo project "lives" in the second instance of eclipse), acceleo does not recognize the template's metamodel, although it is correct. I have to change the name of the metamodel first and then rename it to its correct name again for acceleo to recognize the metamodel.
Something i could try about this?

Thanks for your help, really nice support here Smile
Re: [Acceleo 3] pass arguments in run configuration [message #690894 is a reply to message #690615] Thu, 30 June 2011 11:48 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

The Run Configuration was buggy with this feature since it was used for two different features at the same time. It was use to enter the path of properties files and to enter arguments that would be used during the generation. Now, the configuration has been simplified and you can enter in the run configuration the path of properties files just like in the "getProperties()" method.

If you want to get the old behavior back, you can launch it with the Java Application mode and change the main method of the generated Java class to from this:

 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>();
                
                Workflow generator = new Workflow(modelURI, folder, arguments);
                                 
                for (int i = 2; i < args.length; i++) {
                    generator.addPropertiesFile(args[i]);
                }
                
                generator.doGenerate(new BasicMonitor());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


to that:

 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>();
                                                
                for (int i = 2; i < args.length; i++) {
                    arguments .add(args[i]);
                }
                Workflow generator = new Workflow(modelURI, folder, arguments);
                
                generator.doGenerate(new BasicMonitor());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


After all, the Run Configuration of Acceleo is just the Java one with a new look an few more widgets, you type anything you want in this configuration and you can use it as you want later.

As for your bug, do you have the "automatic build activated"? (Project -> Build Automatically).

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo 3] pass arguments in run configuration [message #691157 is a reply to message #690894] Thu, 30 June 2011 20:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Stephane

I don't understand why a minor version change has removed this user
interface facility.

Surely arguments are much more useful than properties, which if required
can be passed as -properties=... ? the converse doesn't work.

And the Acceleo documentation in the RunConfigurations section shows a
picture of an Acceleo Tab with
a properties panel and a description of how to add arguments one per line.

[The comments in

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

/*
* 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.
*/

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

make no sense to me. Surely the args/arguments need mutual filtering,
and how is this code protected from regeneration?]

Please put the command line arguments facility back.

Regards

Ed Willink

On 30/06/2011 13:48, Stephane Begaudeau wrote:
> Hi,
>
> The Run Configuration was buggy with this feature since it was used
> for two different features at the same time. It was use to enter the
> path of properties files and to enter arguments that would be used
> during the generation. Now, the configuration has been simplified and
> you can enter in the run configuration the path of properties files
> just like in the "getProperties()" method.
>
> If you want to get the old behavior back, you can launch it with the
> Java Application mode and change the main method of the generated Java
> class to from this:
>
> 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>();
> Workflow generator = new
> Workflow(modelURI, folder, arguments);
> for (int i = 2; i <
> args.length; i++) {
> generator.addPropertiesFile(args[i]);
> }
> generator.doGenerate(new BasicMonitor());
> }
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
> to that:
>
> 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>();
> for (int
> i = 2; i < args.length; i++) {
> arguments .add(args[i]);
> }
> Workflow generator = new Workflow(modelURI, folder,
> arguments);
> generator.doGenerate(new BasicMonitor());
> }
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
>
> After all, the Run Configuration of Acceleo is just the Java one with
> a new look an few more widgets, you type anything you want in this
> configuration and you can use it as you want later.
>
> As for your bug, do you have the "automatic build activated"? (Project
> -> Build Automatically).
>
> Regards,
>
> Stephane Begaudeau, Obeo
>
> --
> Twitter: http://twitter.com/#!/sbegaudeau
> Blog: http://stephanebegaudeau.tumblr.com
> Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo 3] pass arguments in run configuration [message #691791 is a reply to message #691157] Sat, 02 July 2011 10:55 Go to previous message
the_ch40s is currently offline the_ch40sFriend
Messages: 14
Registered: April 2011
Junior Member
Thanks for the clarification regarding argument-passing Smile

As for the bug :
Yes, "automatic build" is activated. Interestingly enough, when i ran eclipse to look if the setting was activated, the bug did not occur (i believe that was the first time it did work without renaming the metamodel first (in the new acceleo version)).
Previous Topic:Add annotation to a method in Eclipse
Next Topic:Text-to-Model transformation
Goto Forum:
  


Current Time: Tue Apr 23 07:00:28 GMT 2024

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

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

Back to the top