Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo 3.2.X & Java & Maven] Tutorial for developpers [solved]
[acceleo 3.2.X & Java & Maven] Tutorial for developpers [solved] [message #754555] Thu, 03 November 2011 09:27 Go to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Hello,

I have some questions on the utilisation of Acceleo 3.

First, is there a tutorial or API for developpers, in order to use the core of this tool with Maven and old plain java code, and outside of the Eclipse UI ?

If I understood all what i read on this tool, it works on the same workflow of JJtree & JavaCC, for example. From a .mtl file which described the transformation from a model to a text file, Acceleo generates a set of java classes. These classes are then used to perform transformation of a given model.

I already take a look at this topic (www.eclipse.org/forums/index.php/m/654537/?srch=ant#msg_689894), but when i tried to use the same method (creating a java class that extends AbstractAcceleoGenerator), it results in a NoSuchMethodError.

To be more precise, i have downloaded the runtime of acceleo 3.2.0, and i have used the maven goal eclipse:to-maven (maven.apache.org/plugins/maven-eclipse-plugin/to-maven-mojo.html) in order to add the acceleo's eclipse plugins into my local maven repository.

Then, i have created my class (which extends AbstractAcceleoGenerator). The compilation worked fine, but the execution of the code super.registerResourceFactories(resourceSet) gives an error where the method org.eclipse.emf.ecore.resource.Resource$Factory$Registry.getContentTypeToFactoryMap()Ljava/util/Map does not exists in the jvm. I have tried the same manipulation in another project with the ATL framework (addition in the local repository, compilation, execution), and it works fine.

I think it is a problem in the dependency resolution mechanism performed by maven, but i don't know how to solve it (and if there is any solution) ...

My second question is : if it is not possible to do the job with acceleo 3, is there any solution to make it with acceleo 2 ? If yes, is there any API/tutorial for developpers for Acceleo 2 ?

[Updated on: Thu, 24 November 2011 08:24]

Report message to a moderator

Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #755059 is a reply to message #754555] Mon, 07 November 2011 09:06 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

In order to build an Acceleo generator with maven, you should have a look at the pom.xml provided by Acceleo. You should right click on your Acceleo project and then select configure -> generate pom.xml.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #755102 is a reply to message #755059] Mon, 07 November 2011 11:54 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Hi stephane,

First of all, thanks for your answer. I appreciate your help.

The POM that is generated worked with Tycho, which is a tool which "try" (in my opinion) to provide Maven support for Eclipse's products builds.

What i want is to generate an Acceleo Generator with maven, but as much as possible outside of the Eclipse's world. I mean, the only dependency that seems to be necessary is with the core of Acceleo. Is it possible to generate an Acceleo Generator with plain Java code ? I hope the answer is yes. In my opinion, i only need the metamodel of the source, the source itself (a model), and the transformation files (*.mtl) ? Am i correct ?

I saw in the generated POM that there is a call to the maven-antrun plugin. Is it possible for an acceleo generator to be generate with ant ?

Regards,

P.-C. Bue
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #755104 is a reply to message #755102] Mon, 07 November 2011 12:12 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Another thing :

In the generated POM of one of the Acceleo example on eclipse (ecore2python), the maven exec plugin is called on a class which doesn't exists in the workspace. I think this class defines the compilation itself by extending AcceleoCompiler.java. What is the correct argument ? What is the main class to be called ?
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #755700 is a reply to message #755104] Wed, 09 November 2011 10:44 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,

You can find here an example of a complete working example on an Acceleo generator built with Tycho. The Java class that you are talking about is generated along with the pom.xml file, you can find an example of this class here.

Quote:
I mean, the only dependency that seems to be necessary is with the core of Acceleo. Is it possible to generate an Acceleo Generator with plain Java code ?


Yes you "only" need the Acceleo runtime but it has some dependencies to EMF and OCL. And yes it is possible to launch a generation from Java out of Eclipse. If you want to use an Acceleo generator out of Eclipse, here is a picture of the dependencies needed to run a (in my case UML to Java) generator. In this picture, you can see that you will need EMF (to handle models), OCL (for the expressions), Acceleo and the dependencies of your metamodel. In order to compile, you would need the Acceleo parser too and I think that it would be enough.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #756595 is a reply to message #755700] Mon, 14 November 2011 13:24 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Dear stephane,

I tried the example you send to me, and it works fine with tycho.
Now, i want to test Acceleo outside of tycho.

The workflow is the following :
1- I download the acceleo runtime from eclipse.org/modeling/m2t/downloads/?project=acceleo
2- I put the 5 core plugins of acceleo in my local maven repository (using the eclipse:to-maven goal)
3- I run "mvn package" on my project
3.1- At this point, maven use the Acceleo's plugins i put in my local repository, and retrieve the needed others from the central repository (in particular, the eclipse ones)

When the compilation reach the execution of AcceleoCompiler, i have the following error :
java.lang.NoSuchMethodError: org.eclipse.emf.ecore.resource.Resource$Factory$Registry.getContentTypeToFactoryMap()Ljava/util/Map;

I think i have an error of dependency in the maven dependency resolution, but i don't know where is the problem ...


I see in your previous email that the project you showed to me was from a netbeans project. Is this project a standalone project ? Or is it an import of an eclipse project in the netbeans ide ?
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #756612 is a reply to message #755700] Mon, 14 November 2011 14:12 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
ok i found he cause of the problem :

If i run the acceleo project using tycho, maven resolve emf to be in version 2.7 ... while if i run the same project using maven itself, emf is resolves to 2.3 ...
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #756842 is a reply to message #756612] Tue, 15 November 2011 10:24 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,

In the pom.xml generated by Acceleo, we are using the Eclipse Indigo update site which contains EMF 2.7:

<profiles>
    <profile>
      <id>platform-indigo</id>
      <activation>
         <activeByDefault>true</activeByDefault>
        <property>
          <name>platform-version-name</name>
          <value>indigo</value>
        </property>
      </activation>
      <properties>
        <eclipse-site>http://download.eclipse.org/releases/indigo</eclipse-site>
        <platform-version>[3.7,3.8)</platform-version>
      </properties>
    </profile>
  </profiles>

  <repositories>
    <repository>
      <id>eclipse-platform</id>
      <layout>p2</layout>
      <url>${eclipse-site}</url>
    </repository>
    <repository>
      <id>acceleo</id>
      <layout>p2</layout>
      <url>${acceleo-site}</url>
    </repository>
  </repositories>


You can change the update site in which you want tycho to find the dependencies. With your regular maven build, you must be using the EMF jars from your Eclipse installation which seems to be an Eclipse 3.3 that includes EMF 2.3. You can download an Eclipse 3.7 to use the latest version of EMF. By the way, Acceleo is not supported on Eclipse 3.3 (it """"may"""" work but we don't support it).

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #757429 is a reply to message #756842] Fri, 18 November 2011 12:18 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Thanks Stephane for your valuable answers, i appreciate it.

In fact, i have installed Acceleo on Eclipse 3.7, and i have transfered all the eclipse plugins in the installation directory in my local maven repository using eclipse:to-maven goal. It works fine, but i still get errors on the compilation of the .tml files that you give me on your example.

Here they are :

[ERROR] 16:Module org::obeonetwork::pim::uml2::gen::java::common::common not found.
[ERROR] 17:Module org::obeonetwork::pim::uml2::gen::java::common::declaration not found.
[ERROR] 18:Module org::obeonetwork::pim::uml2::gen::java::common::type not found.
[ERROR] 23:Cannot find operation (genVisibility()) for the type (Property)
[ERROR] 23:Cannot find operation (genFinal()) for the type (Property)
[ERROR] 23:Cannot find operation (genStatic()) for the type (Property)
[ERROR] 23:Cannot find operation (genType()) for the type (Property)
[ERROR] 23:Cannot find operation (genName()) for the type (Property)
[ERROR] 23:Cannot find operation (genDefaultValue()) for the type (Property)
[ERROR] 35:Cannot find operation (genVisibility()) for the type (Property)
[ERROR] 35:Cannot find operation (genFinal()) for the type (Property)
[ERROR] 35:Cannot find operation (genStatic()) for the type (Property)
[ERROR] 35:Cannot find operation (genType()) for the type (Property)
[ERROR] 35:Cannot find operation (genName()) for the type (Property)
[ERROR] 35:Cannot find operation (genDefaultValue()) for the type (Property)
[ERROR] 51:Cannot find operation (genName()) for the type (Property)

Do you have any idea on how to solve it ? Seems to be an error on the visibility of each mtl files between each other ...

[edit]
I have just noted that the Maven compilation leads to the separation of the "emtl" files and the "class" files, maybe the problem comes from that ...
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #758167 is a reply to message #757429] Tue, 22 November 2011 08:39 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

Quote:
I have just noted that the Maven compilation leads to the separation of the "emtl" files and the "class" files, maybe the problem comes from that ...


I the emtl files are not found, the compilation will not work (dependencies will be missing). You can have a look at the generated Java class and look at the method computeDependencies(...) to see where Acceleo look for the other emtl files. This method is protected to let user the ability to customize where the dependencies should be looked for.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [acceleo 3.2.X & Java & Maven] Tutorial for developpers [message #758678 is a reply to message #758167] Thu, 24 November 2011 08:22 Go to previous message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
I finally found why the Acceleo compiler didn't found such emtl files.
I put the wrong parameter in the source files to consider (problem of path references).

And, finally, it works fine out of Eclipse !!!

For those who are interested in, here is the solution i found :

- Install Acceleo on a classic Eclipse installation,
- Use the maven goal eclipse:to-maven, and give with the parameter "-DeclipseDir" the path to your eclipse installation. This will put all your eclipse's plugins actually installed on your local maven repository, including Acceleo and its dependencies.
- Run the goal package on the project associated to this post. Use a diff in order to check if the data generated (data/out) are correct wrt the oracle (data/out_oracle)

Thank you Stephane for your help, i appreciate a lot.
Previous Topic:[Acceleo 3.1.2][resolved] Custom code lost in some protected area
Next Topic:[JET] Unable to retrieve stereotype list of a UML element in an XPath function
Goto Forum:
  


Current Time: Thu Mar 28 10:39:31 GMT 2024

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

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

Back to the top