i am trying to generate Java Code from an .ecore
meta model with OCL contstraints during a maven-tycho build.
I have managed to get code generation to work within Eclipse, but the tycho build does not generate code for OCL.
Setup
I have an Ecore meta-model named model.ecore
with embedded OCL Constraints (OCLInEcore).
Since I don't want to use delegates i have
<genAnnotations source="http://www.eclipse.org/OCL/GenModel">
<details key="Use Delegates" value="false"/>
<details key="Use Null Annotations" value="true"/>
</genAnnotations>
in the corresponding model.genmodel
file alongside with the operationReflection="true"
.
This works fine when I open the Genmodel in Eclipse and choose "Generate Model Code" in the Genmodel Editor.
Problem
I want to call code generation from an .mwe2
modelling workflow to integrate the code generation in my maven-tycho build.
Currently, my workflow file looks like this
module Generate
import org.eclipse.xtext.ecore.EcoreSupport
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.emf.mwe.utils.StandaloneSetup
import org.eclipse.emf.mwe2.ecore.EcoreGenerator
import org.eclipse.emf.mwe2.runtime.workflow.Workflow
var rootPath
var pluginID
Workflow {
bean = EcoreSupport {}
bean = ResourceSetImpl : resourceSet {}
bean = StandaloneSetup {
resourceSet = resourceSet
platformUri = rootPath
scanClassPath = true
}
component = EcoreGenerator {
resourceSet = resourceSet
genModel = "platform:/resource/${pluginID}/model/model.genmodel"
srcPath = "platform:/resource/${pluginID}/src-gen/"
generateEdit = true
generateEditor = true
}
}
which is called during the generate-sources
phase:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>mwe2Launcher</id>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
<arguments>
<argument>${project.baseUri}/Generate.mwe2</argument>
<argument>-p</argument>
<argument>rootPath=${project.parent.basedir}</argument>
<argument>-p</argument>
<argument>pluginID=${project.artifactId}</argument>
</arguments>
<classpathScope>compile</classpathScope>
<includePluginDependencies>true</includePluginDependencies>
<includeProjectDependencies>true</includeProjectDependencies>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
<stopUnresponsiveDaemonThreads>true</stopUnresponsiveDaemonThreads>
</configuration>
<dependencies>
...
</dependencies>
</plugin>
The problem is that this seems to simply skip the relevant code generation for OCL.
I have found This bug report which pointed me towards these two projects org.eclipse.ocl.examples.build and org.eclipse.ocl.examples.codegen, but I'm struggling to figure out how to stick those pieces together.
Am I missing something obvious here?