serializationeclipse-plugineclipse-emf

EMF: How to create model instance programmatically without using eclipse instance


With EMF I can import an ecore file (metamodel), generate the code then debug the project as a new eclipse instance to play with my model instance. My purpose is to create my instance without loading a new eclipse instance, for example I would like to create a new Java project that use my generated code to create the instance assuming that I'll do some validation/OCL to have an instance that I can serialize to an XMI file.

I was thinking about export the generated code (Model, Edit, Editor) to a JAR file or as a plugin, but it didn't work perfectly. Do you have any suggestion or HowTo?


Solution

  • I am not sure what you mean by "without loading a new eclipse instance", but if you want to get rid of the EMF and Eclipse-dependencies you can achieve this by editing your genmodel. This recipe explains the steps in detail: http://wiki.eclipse.org/EMF/Recipes#Recipe:_Generating_Pure_API_With_No_Visible_EMF_Dependencies

    Not everything EMF has to offer will work with this solution, but it might be sufficient for what you want.