Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo] please see the method named "registerPackages" in the Java launcher of your gene
[acceleo] please see the method named "registerPackages" in the Java launcher of your gene [message #705370] Fri, 29 July 2011 19:52 Go to next message
Leonardo Kenji Shikida is currently offline Leonardo Kenji ShikidaFriend
Messages: 37
Registered: July 2009
Member
Hi

I´ve generated a new UI acceleo project, but in the generateAll() method, I want to create a new model in memory instead of reading from the emf model instance, like this

	public void doGenerate(IProgressMonitor monitor) throws IOException {
		if (!targetFolder.getLocation().toFile().exists()) {
			targetFolder.getLocation().toFile().mkdirs();
		}
		monitor.subTask("Loading...");

///////////
		PrestoFactory factory = PrestoFactory.eINSTANCE; 
		Sistema sistema = factory.createSistema();
		sistema.setName("xxx");
		sistema.setPacote("com.xxx.yyy");
		TipoPlataforma tipo = TipoPlataforma.XXX;
		sistema.setTipo(tipo);
///////////
		
		xxx.main.Generate gen0 = new xxx.main.Generate(sistema, targetFolder.getLocation().toFile(), arguments);
		//xxx.main.Generate gen0 = new xxx.main.Generate(modelURI, targetFolder.getLocation().toFile(), arguments);
		monitor.worked(1);
		String generationID = org.eclipse.acceleo.engine.utils.AcceleoLaunchingUtil.computeUIProjectID("xxx", "xxx.main.Generate", modelURI.toString(), targetFolder.getFullPath().toString(), new ArrayList<String>());
		gen0.setGenerationID(generationID);
		gen0.doGenerate(BasicMonitor.toMonitor(monitor));
			
		
	}


so in the doGenerate() method (the last one above), I´ve got in the stage eclipse instance

"The generation fail 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."

and in the launcher eclipse instance

"!ENTRY org.eclipse.acceleo.engine 2 0 2011-07-29 16:48:20.682
!MESSAGE The generation fail 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. "

This method is, of course

    public void registerPackages(ResourceSet resourceSet) {
        super.registerPackages(resourceSet);
        
        /*
         * 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);
         * }
         */
}


however, It´s not clear to me what exactly should I do here. Should I add the code for my XXXPackage.class? In this case, how my acceleo eclipse project will "see" my generated EMF java classes?

Thanks in advance

Kenji

[Updated on: Fri, 29 July 2011 19:54]

Report message to a moderator

Re: [acceleo] please see the method named "registerPackages" in the Java launcher of your [message #707118 is a reply to message #705370] Mon, 01 August 2011 09:01 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1639
Registered: July 2009
Senior Member
Kenji,

Indeed, what you need to register in this metod is the metamodel of the model you use as input of your generation, which would give something like
resourceSet.getPackageRegistry().put(XXXPackage.eNS_URI, XXXPackage.eINSTANCE);
.

This is all that is needed if your metamodel is installed as a plugin in your Eclipse. If you have the metamodel in your workspace, however, you will need the whole "if - else".

Laurent Goubet
Obeo
Re: [acceleo] please see the method named "registerPackages" in the Java launcher of your [message #723443 is a reply to message #707118] Thu, 08 September 2011 15:05 Go to previous message
Leonardo Kenji Shikida is currently offline Leonardo Kenji ShikidaFriend
Messages: 37
Registered: July 2009
Member
I finally deployed my Acceleo tool down here using an eclipse update site. I think I´ll spend a little more time documenting the whole process and making this public to help others to do the same Wink

Thanks

Kenji
Previous Topic:[JET] invoke a startTemplate (ie a template which use other templates) from Java?
Next Topic:IOException with exported Acceleo project [resolved]
Goto Forum:
  


Current Time: Sun Dec 21 23:17:09 GMT 2014

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

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