|
|
|
|
Re: [Acceleo] Custom Acceleo metamodel [message #1734648 is a reply to message #1734645] |
Fri, 10 June 2016 07:42 |
Jakub Kitaj Messages: 8 Registered: February 2016 |
Junior Member |
|
|
The generated "registerPackages" method is:
@Override
public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
/*
* 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.
*/
/*
* 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.
*
* 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 the package is located in another plug-in, already installed in Eclipse. The following content should
* have been generated at the beginning of this method. Do not register the package using this mechanism if
* the metamodel is located in the workspace.
*
* if (!isInWorkspace(UMLPackage.class)) {
* // The normal package registration if your metamodel is in a plugin.
* resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
* }
*
* If the package is located in another project in your workspace, the plugin containing the package has not
* been register by EMF and Acceleo should register it automatically. If you want to use the generator in
* stand alone, the regular registration (seen a couple lines before) is needed.
*
* To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
*/
}
I think, I should write something like:
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
but from can I get package class for my metamodel (like UMLPackage above) ?
Can you show your "registerPackages" method?
[Updated on: Fri, 10 June 2016 07:48] Report message to a moderator
|
|
|
|
|
|
|
Re: [Acceleo] Custom Acceleo metamodel [message #1736163 is a reply to message #1736094] |
Mon, 27 June 2016 08:21 |
|
Hi Jakub,
Please look at Viktoria's example, as well as those that are pre-generated for you in the java class beside your main template : what you need to "put" in the package registry is the instance of your metamodel's package.
You should have an ecore model you've created with the URI "http://org/model/ros" , and you have generated the code corresponding to that model. In that code, you have a class named "RosPackage" (or "XyzPackage", xyz being the name of your model's EPackage). what you need to pu in the "registerPackages" method is :
resourceSet.getPackageRegistry().put("http://org/model/ros", RosPackage.eINSTANCE);
You will need to have a dependency between the project that contains your acceleo templates and the project that contains your generated model code for this to work.
Laurent Goubet
Obeo
|
|
|
Powered by
FUDForum. Page generated in 0.02994 seconds