| [Acceleo] Launch a transformation by code [message #799133] |
Wed, 15 February 2012 08:38  |
JM Gauthier Messages: 25 Registered: June 2011 |
Junior Member |
|
|
Hi,
I am working on a transformation M2T with Acceleo, and I would like to transform a xmi file myFile.xmi which is conform to a meta model into a vhdl-ams file. The transformation work fine with the Run Configuration from Eclipse. But now I wish to automate this transformation by java code.
I am trying to use the java class generated by Acceleo like this :
URI modelURI = URI.createFileURI("/test/myFile.xmi");
File folder = new File("/test/");
List<String> arguments = new ArrayList<String>();
Xmi2Vhdlfile generator = new Xmi2Vhdlfile(modelURI, folder, arguments);
generator.doGenerate(new BasicMonitor());
This code is situated in another class in order to launch the transformation from a plugin.
Actually, I am trying to do as the main in the Xmi2Vhdlfile.java. Moreover, I use the registerPackages method as it is explain to register my Vhdlams meta model:
if (!isInWorkspace(VhdlamsPackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put(VhdlamsPackage.eNS_URI, VhdlamsPackage.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/MyVhdlMetamodel.ecore", VhdlamsPackage.eINSTANCE);
}
The problem is when the code above is launched, I get the classic 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.
What is weird, is that the vhdlams metamodel is well registered in the EMF Registry..
So, is my code correct to do the transformation ? Is it a good practice ?(like the main method)
Moreover do I have to use the registerResourceFactories method to explain Acceleo that my source model is a xmi file ?
Thanks for advance.
Edit : I am using Acceleo SDK 3.2.0 with Eclipse Indigo MDT SR1
[Updated on: Wed, 15 February 2012 08:50] Report message to a moderator
|
|
|