[Acceleo] Use Ecore metamodel in the Acceleo editor without installing a plugin [message #1767213] |
Mon, 03 July 2017 15:32  |
Mad Vin Messages: 40 Registered: September 2013 |
Member |
|
|
Hello,
Is it possible to type the instances of the objects in the Acceleo editor with types defined in a personal Ecore, defined in a project of the Eclipse workspace, without installing it by a plugin in the Eclipse platform ?
I mean, i define a personal Ecore metamodel "myEcore" in my Eclipse workspace in the project "MyEcoreProject". This Ecore have the URI : "http://myEcore". In this Ecore, i have defined a class named "MyType", and i would like to use this type in the Acceleo editor, for example like this :
[query public myQuery(arg : Integer) : myEcore::MyType = ... /]
To do this, i know i have to add the URI of my Ecore in the [module] tag of my Acceleo module file, but by default Acceleo editor doesn't recognize this URI as a valid one. The only way i have found for now for Acceleo editor to know it is to generate myEcore code and to install it in the Eclipse platform as a plugin :
1) Is there a way Acceleo recognizes this URI without installing myEcore as a plugin in my Eclipse platform ?
2) When i have not installed my Ecore as a plugin, If i use the completion (CTRL+SPACE) in the [module] tag of my Acceleo file, it proposes me the URI '/MyEcoreProject/model/myEcore.ecore', and if i add it in the tag, it displays this URI is unknown by Acceleo. So why this URI is proposed and how to use it if we can ?
Thank you.
|
|
|
|
Re: [Acceleo] Use Ecore metamodel in the Acceleo editor without installing a plugin [message #1767225 is a reply to message #1767216] |
Mon, 03 July 2017 17:56   |
Mad Vin Messages: 40 Registered: September 2013 |
Member |
|
|
Sorry I understand what you are talking about, but i don't see how to do it correctly...
For your information :
- my metamodel is very simple : it just includes some simple classes and enumerations. I've stored it in an EmfProject containing the .ecore file, the associated .genmodel file, the generated Java code of the metamodel, and the useful files to define an Eclipse plugin (MANIFEST.MF).
- I just want to use this metamodel in my Acceleo modules : this metamodel is not used to create models stored in files, but only to create and manage internal structures in the Acceleo modules and during the Acceleo transformation. The model I use as input for the Acceleo transformation is a simple UML one. So i just need the Acceleo editor recognizes the elements defined in my metamodel during the edition, and that Acceleo executes my modules using my metamodel properly.
- I've referenced my "EmfProject" in the required plugins of my Acceleo project (in MANIFEST.MF)
So you mean that i can use :
[module generate('/EmfProject/model/MyEcore.ecore')] isn't it or not ?
In the Java startup class, i don't really understand what to insert : in the "registerPackages" method, the documentation says "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." This sentence means for me that Acceleo can locate the package of my metamodel alone, but it seems not... Nevertheless I've tried to add :
if (!isInWorkspace(MyEcorePackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put(MyEcorePackage.eNS_URI, MyEcorePackage.eINSTANCE);
}
and
if (!isInWorkspace(MyEcorePackagePackage.class)) {
// The normal package registration if your metamodel is in a plugin.
resourceSet.getPackageRegistry().put("/EmfProject/model/MyEcore.ecore", MyEcorePackagePackage.eINSTANCE);
}
but it doesn't work : Acceleo editor still does not know '/EmfProject/model/MyEcore.ecore' neither 'http://myEcore' (it is the value of MyEcorePackage.eNS_URI). Which part of the Acceleo project is editable to have an effect on the Acceleo editor ?
I've tried too to clean the projects and restart Eclipse, but same result.
So where i've done wrong ?
Thank you.
[Updated on: Mon, 03 July 2017 18:30] Report message to a moderator
|
|
|
|
|
Re: [Acceleo] Use Ecore metamodel in the Acceleo editor without installing a plugin [message #1767255 is a reply to message #1767235] |
Tue, 04 July 2017 08:37   |
|
Hi,
We do not recommand trying to develop your modules with the metamodel in your workspace. As Ed mentionned it can work... but it is very error prone and subject to bugs. Installing the plugin or, easier for development time if your metamodel is still subject to changes, using a runtime eclipse to develop your modules (have your metamodel in first eclipse then run a new eclipse application from there and develop your modules in that second one), is the recommanded way.
Laurent Goubet
Obeo
|
|
|
|
Powered by
FUDForum. Page generated in 0.02222 seconds