Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2t-dev] acceleo maven plugin

Hello,

Thanks for the quick answer.

I have looked to the code I am using: it is the one of the official acceleo maven plugin org.eclipse.acceleo.maven-tests, I have have just made a checkout of it:

http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git/tree/tests/org.eclipse.acceleo.maven.tests/src/main/java/org/eclipse/acceleo/module/example/uml2java/helios/GenerateJava.java from the git reprository

 

(I have just added the system outprint to be sure where It goes through B )

 

The method you are referencing me seems to be there

Nevertheless, I am getting the error

 

I get one error:

The generation failed to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates.

The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator. It could also come from a missing [comment @main/]

in the template used as the entry point of the generation.

 

Francois

 

Code extracted from

http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git/tree/tests/org.eclipse.acceleo.maven.tests/src/main/java/org/eclipse/acceleo/module/example/uml2java/helios/GenerateJava.java

 

/**

       * Updates the registry used for looking up a package based namespace, in the resource set.

       *

        * @param resourceSet

       *            is the resource set

       * @generated

       */

       @Override

       public void registerPackages(ResourceSet resourceSet) {

             System.out.println("A");

        super.registerPackages(resourceSet);

        if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {

             System.out.println("B");

            resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);

       }

        else{

             System.out.println("C");

        }

       

        /*

         * TODO If you need additional package registrations, you can register them here. The following line

         * (in comment) is an example of the package registration for UML. 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. You can use the method

         * "isInWorkspace(Class c)" to check if the package that you are about to register is in the workspace.

         * To register a package properly, please follow the following conventions:

         *

         * if (!isInWorkspace(UMLPackage.class)) {

         *     // The normal package registration if your metamodel is in a plugin.

         *     resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

         * } else {

         *     // The package registration that will be used if the metamodel is not deployed in a plugin.

         *     // This should be used if your metamodel is in your workspace and if you are using binary resource serialization.

         *     resourceSet.getPackageRegistry().put("/myproject/myfolder/mysubfolder/MyUMLMetamodel.ecore", UMLPackage.eINSTANCE);

         * }

         *

         * To learn more about Package Registration, have a look at the Acceleo Launcher documentation (Help -> Help Contents).

         */

    }

 

 

De : m2t-dev-bounces@xxxxxxxxxxx [mailto:m2t-dev-bounces@xxxxxxxxxxx] De la part de Stéphane Bégaudeau
Envoyé : jeudi 20 novembre 2014 10:26
À : Model to Text
Objet : Re: [m2t-dev] acceleo maven plugin

 

Hi,

 

You need to register your metamodel in the Java launcher of your generator (the Java class generated next to your main module) in its registerPackages method. You can see an example on Github [1].

 

Regards,

 

Stephane Bégaudeau, Obeo

 

 

Le 18 nov. 2014 à 17:52, LE FEVRE FRANCOIS <francois.le-fevre@xxxxxx> a écrit :

 

Dear Accelo maven plugin community,

I have just tried to setp up a small example of accelo maven plugin.

 

I get one error:

The generation failed to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates. 

The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator. It could also come from a missing [comment @main/]

in the template used as the entry point of the generation.

 

I have used the example maven project /org.eclipse.acceleo.maven.tests

When I run the mvn install, it generates well the class, the emlt files and the artifact.

 

Then I have created a small maven project with an uml model, the same of the example

I have defined in my pom the call of the previous plugin.

 

 

<plugin>

                          <groupId>org.eclipse.acceleo</groupId>

                           <artifactId>org.eclipse.acceleo.maven.launcher</artifactId>

                          <version>3.5.0-SNAPSHOT</version>

                          <executions>

                                 <execution>

                                       <phase>process-resources</phase>

                                       <goals>

                                              <goal>acceleo-launcher</goal>

                                       </goals>

                                 </execution>

                          </executions>

                          <configuration>

                          <generatorClass>org.eclipse.acceleo.module.example.uml2java.helios.GenerateJava</generatorClass>

                                

                                 <model>${basedir}\src\main\model\example.uml</model>

                                 <outputFolder>${basedir}\src</outputFolder>

                          </configuration>

                          <dependencies>                                <dependency>

                                       <groupId>org.eclipse.acceleo</groupId>

                                       <artifactId>org.eclipse.acceleo.maven-test</artifactId>

                                       <version>3.6.0-SNAPSHOT</version>

                                 </dependency>

                          </dependencies>

                    </plugin>

 

But whatever I do it generates the error

please see the method named "registerPackages" in the Java launcher of your generator. It could also come from a missing [comment @main/]

 

I have checked that in my /org.eclipse.acceleo.maven.tests/src/main/java/org/eclipse/acceleo/module/example/uml2java/helios/generateJava.mtl

I have the following lines:

[template public generateClass(c : Class)]

[comment @main /]

 

Thanks for your help.

 

 

Francois

 

_______________________________________________
m2t-dev mailing list
m2t-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/m2t-dev

 


Back to the top