Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Maven plugin difficulties
Maven plugin difficulties [message #1480490] Thu, 20 November 2014 08:16 Go to next message
Francois Le Fevre is currently offline Francois Le FevreFriend
Messages: 56
Registered: October 2014
Location: Paris Saclay, France
Member
Hello Acceleo community,
I have posted this topic another forum but I have discovered this one now and I find it more apropriate.

When trying to generate java code from an uml model with the acceleo maven plugin in standalone mode (without eclipse) I have the following 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 downloaded the source of acceleo.
I have focused on the project/module : /org.eclipse.acceleo.maven.tests
I have just changed the following part in the pom to be sure the accelo plugin is called to compile the mlt files

<plugin>
				<groupId>org.eclipse.acceleo</groupId>
				<artifactId>org.eclipse.acceleo.maven</artifactId>
				<version>3.5.0-SNAPSHOT</version>
				<executions>
					<execution>
						<phase>compile</phase>
						<goals>
							<goal>acceleo-compile</goal> XXXHEREXXXX
						</goals>
					</execution>
				</executions>
				<configuration> <useBinaryResources>false</useBinaryResources> <usePlatformResourcePath>true</usePlatformResourcePath> 
					<acceleoProject> <root>${project.basedir}</root> <entries> <entry> <input>src/main/java</input> 
					<output>target/classes</output> </entry> </entries> </acceleoProject> <packagesToRegister> 
					<packageToRegister>org.eclipse.uml2.uml.UMLPackage</packageToRegister> </packagesToRegister> 
					</configuration>
			</plugin>


The emlt files are well generated
Then I have create a second maven project with an uml model in it, the one of acceleo example.uml
I have called the plugin generated with the previous module

<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.sample.main.Generate</generatorClass -->
					<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.tests</artifactId>
						<version>3.6.0-SNAPSHOT</version>
					</dependency>
				</dependencies>
			</plugin>


But I am getting everytime the error

[INFO] Generation completed.
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. 
[INFO] 


I have checked that /org.eclipse.acceleo.maven.tests/src/main/java/org/eclipse/acceleo/module/example/uml2java/helios/generateJava.mtl
contains
[template public generateClass(c : Class)]
[comment @main /]


and that /org.eclipse.acceleo.maven.tests/src/main/java/org/eclipse/acceleo/module/example/uml2java/helios/GenerateJava.java

contains
@Override
	public void registerPackages(ResourceSet resourceSet) {
		System.out.println("kjkj");
        super.registerPackages(resourceSet);
        if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
        	System.out.println("kjkjaa");
            resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
        }
        
        /*
         * 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).
         */
    }

no idea any more...

thanks for your help
Re: Maven plugin difficulties [message #1489786 is a reply to message #1480490] Thu, 27 November 2014 17:34 Go to previous message
Francois Le Fevre is currently offline Francois Le FevreFriend
Messages: 56
Registered: October 2014
Location: Paris Saclay, France
Member
Dear all,
finally I was able to compile the different official mtl files from org.eclipse.umlgen.gen.java
I also succeed to use the maven acceleo plugin
but when I try to generate the java code, I have only a scafold that do not compile at all.
very strange

For example, I have used the small example provided here:
http://git.eclipse.org/c/umlgen/org.eclipse.umlgen.git/tree/org.eclipse.umlgen.gen.java/tests/org.eclipse.umlgen.gen.java.tests/model/example.uml

I should have a Person.java class with several attributes like name etc..
I only get the following codes.


do you have any idea why?

/*******************************************************************************
 * File generated from the model::org.eclipse.acceleo.java::Person uml Class
 * Generated by the Acceleo 3 <i>UML to Java</i> generator.
 * Date: 27 novembre 2014 18:22:33 CET
 *******************************************************************************/
package org.eclipse.acceleo.java;

import ;
import java.util.Date;
// Start of user code (user defined imports)

// End of user code

/**
 * Description of Person.
 * 
 * @author 
 */


}
Previous Topic:[ACCELEO] Problem with casting
Next Topic:[Acceleo - Papyrus] Package with uri '--- ActionLanguage-Profile' not found.
Goto Forum:
  


Current Time: Tue Jan 16 23:46:16 GMT 2018

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

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