[EMF Ant Task] genModel attribute in plugin.xml not generated [message #1684603] |
Wed, 18 March 2015 13:53 |
Niels Brouwers Messages: 80 Registered: July 2009 |
Member |
|
|
I have experienced PackageNotFound exceptions when opening a dynamic model instance using the Sample Reflective Ecore Model editor. It turns out this was caused by the extension point "org.eclipse.emf.ecore.generated_package" in plugin.xml missing the genModel attribute that points to the instance of the genmodel in the project. See below for an example:
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated Library-->
<package
uri="http://www.eclipse.org/examples/library/1.0"
class="org.eclipse.Library.LibraryPackage"
genModel="model/Library.genmodel"/>
</extension>
Adding the genModel attribute made the dynamic model instances to open just fine in the Sample Reflective Ecore Model editor.
We are using EMF Ant tasks to automate the generation of Java source code from the large amount of Ecore models we maintain. An example of such Ant task is shown below:
<?xml version="1.0"?>
<project name="project" default="genmodel.generate.sources">
<property name="pluginID" value="org.eclipse.Library"/>
<property name="languageName" value="Library"/>
<target name="genmodel.generate.sources">
<emf.Ecore2Java
model="model/${languageName}.ecore"
genModel="model/${languageName}.genmodel"
modelProject="${pluginID}"
reconcileGenModel="keep"
generateModelProject="true"
generateEditProject="true"
generateEditorProject="true"
modelPluginID="${pluginID}"
modelProjectFragmentPath="src"
validateModel="true">
</emf.Ecore2Java>
</target>
</project>
The problem I perceive is now that when generating Java source code, including the plugin.xml, from the Ecore model with the EMF Ant task, the genModel attribute is removed from the extension point declaration.
<extension point="org.eclipse.emf.ecore.generated_package">
<!-- @generated Library-->
<package
uri="http://www.eclipse.org/examples/library/1.0"
class="org.eclipse.Library.LibraryPackage"/>
</extension>
Apparently, the Ant task is not just a wrapper around the EMF code generator but does exhibit different behavior. Did I run into a bug of the EMF Ant task, or do I need to configure it differently?
Alternatively, I could remove the @generated annotation but that is not desired as it could be a root cause of problems when migrating to a newer version of EMF (e.g. in case new attributes of this extension points are introduced).
Thanks!
Kind regards,
Niels Brouwers.
|
|
|
Re: [EMF Ant Task] genModel attribute in plugin.xml not generated [message #1684752 is a reply to message #1684603] |
Wed, 18 March 2015 15:05 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
I used to spend many frustrating days struggling with ANT
declarations/installations/builds, often rediscovering the still open
bugs on Eclipse Ant.
Then I started using MWE2. I cannot recommend it too strongly in comparison.
Unfortunately there does not seem to be a community of third party MWE
components, but you may find quite a few such as GenerateModel and
EcoreGenModelSetup in org.eclipse.ocl.examples.build.
With MWE2 you can debug your code directly in Java without this magic
missing-taskdef land with its own unique variant of your classpath.
Regards
Ed Willink
On 18/03/2015 13:53, Niels Brouwers wrote:
> I have experienced PackageNotFound exceptions when opening a dynamic
> model instance using the Sample Reflective Ecore Model editor. It
> turns out this was caused by the extension point
> "org.eclipse.emf.ecore.generated_package" in plugin.xml missing the
> genModel attribute that points to the instance of the genmodel in the
> project. See below for an example:
>
>
> <extension point="org.eclipse.emf.ecore.generated_package">
> <!-- @generated Library-->
> <package
> uri="http://www.eclipse.org/examples/library/1.0"
> class="org.eclipse.Library.LibraryPackage"
> genModel="model/Library.genmodel"/>
> </extension>
>
>
> Adding the genModel attribute made the dynamic model instances to open
> just fine in the Sample Reflective Ecore Model editor.
> We are using EMF Ant tasks to automate the generation of Java source
> code from the large amount of Ecore models we maintain. An example of
> such Ant task is shown below:
>
>
> <?xml version="1.0"?>
> <project name="project" default="genmodel.generate.sources">
> <property name="pluginID" value="org.eclipse.Library"/>
> <property name="languageName" value="Library"/>
>
> <target name="genmodel.generate.sources">
> <emf.Ecore2Java
> model="model/${languageName}.ecore"
> genModel="model/${languageName}.genmodel"
> modelProject="${pluginID}"
> reconcileGenModel="keep"
> generateModelProject="true"
> generateEditProject="true"
> generateEditorProject="true"
> modelPluginID="${pluginID}"
> modelProjectFragmentPath="src"
> validateModel="true">
> </emf.Ecore2Java>
> </target>
> </project>
>
>
> The problem I perceive is now that when generating Java source code,
> including the plugin.xml, from the Ecore model with the EMF Ant task,
> the genModel attribute is removed from the extension point declaration.
>
> <extension point="org.eclipse.emf.ecore.generated_package">
> <!-- @generated Library-->
> <package
> uri="http://www.eclipse.org/examples/library/1.0"
> class="org.eclipse.Library.LibraryPackage"/>
> </extension>
>
>
> Apparently, the Ant task is not just a wrapper around the EMF code
> generator but does exhibit different behavior. Did I run into a bug of
> the EMF Ant task, or do I need to configure it differently?
>
> Alternatively, I could remove the @generated annotation but that is
> not desired as it could be a root cause of problems when migrating to
> a newer version of EMF (e.g. in case new attributes of this extension
> points are introduced).
>
> Thanks!
|
|
|
|
Powered by
FUDForum. Page generated in 0.03504 seconds