Automating EMF Tasks – Codegeneration

In order to execute the task of code generation of an EMF model, an ant task is quite handy to do this. Here is an example for this:

<exec executable="${eclipse.exe}">
	<arg value="-noSplash" />
	<arg value="-data ${workspace_location}" />
	<arg value="-model" />
	<arg value="-edit" />
	<arg value="-editor" />
	<arg value="-tests" />
	<arg value="-application" />
	<arg value="org.eclipse.emf.codegen.ecore.Generator" />
	<arg value="${genmodel}" />

You can omit parameters like -edit if you do not need these parts.

Currently, I try to find an automation of the following tasks:

  • Clean the code generation (this can also be done using a simple delete command on the filesystem)
  • Create a genmodel from an ecore model
  • Reload a genmodel by an ecore model
  • Start an eclipse instance with the created plugins in its runtime

XText and Eclipse – FeatureMap

I wanted to convert my EMF model to an XText Grammar to generate an editor for my model. However, the feature maps are not supported in XText. Therefore, it is best to remove them. As an XSD is the source of my EMF, i just annotated the xsd:choice constructs with ecore:featureMap=””. Then, XText can create the language.

Other problems arise due to datatypes. For the XML Datatypes, specific IValueConverters have to be registered.