Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Separate workflow project for emf code generation
Separate workflow project for emf code generation [message #1796960] Tue, 23 October 2018 08:10 Go to next message
Jan Jansen is currently offline Jan JansenFriend
Messages: 15
Registered: October 2018
Junior Member
Hi all,

In our project we have several different modules that require code to be generated using an mwe2 workflow file. These workflow files are all identical, except for the model names; this gave us the idea to make a separate project with one workflow file, and just call this from maven with the parameters for the model names and paths to the projects.

What we have now looks like the following:

The workflow project has the following workflow defined (file name is SingleGenerateEmf.mwe2):

module com.project.name

import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.emf.mwe.utils.*

var projectName = "com.project.name.workflow"
var rootPath = ".."
var modelName = "overwritten by pom parameter"

Workflow {
	bean = org.eclipse.xtext.ecore.EcoreSupport {}

	bean = ResourceSetImpl : resourceSet {}
	bean = StandaloneSetup {
		resourceSet = resourceSet
		platformUri = "${rootPath}"
		scanClassPath = true
	}

	component = org.eclipse.emf.mwe2.ecore.EcoreGenerator {
		genModel = "${rootPath}/${projectName}/model/${modelName}.genmodel"
		srcPath = "${rootPath}/${projectName}/emf-gen"
	}
}


This is then called from the parent pom as follows:
                                   <plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>1.4.0</version>
						<executions>
							<execution>
								<id>generateEmf</id>
								<phase>generate-sources</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<arguments>
										<argument>${project.basedir}/workflow/SingleGenerateEmf.mwe2</argument>
										<argument>-p</argument>
										<argument>rootPath=${project.basedir}/..</argument>
										<argument>-p</argument>
										<argument>projectName=com.project.name.expr</argument>
										<argument>-p</argument>
										<argument>modelName=IdlExpr</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
						<configuration>
							<mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
							<classpathScope>compile</classpathScope>
							<includePluginDependencies>true</includePluginDependencies>
							<cleanupDaemonThreads>false</cleanupDaemonThreads><!-- see https://bugs.eclipse.org/bugs/show_bug.cgi?id=475098#c3 -->
						</configuration>
						<dependencies>
							<dependency>
								<groupId>org.eclipse.emf</groupId>
								<artifactId>org.eclipse.emf.mwe2.launch</artifactId>
								<version>${emf-mwe2-launch-version}</version>
							</dependency>
							<dependency>
								<groupId>org.eclipse.xtext</groupId>
								<artifactId>org.eclipse.xtext.common.types</artifactId>
								<version>${xtext.version}</version>
							</dependency>
							<dependency>
								<groupId>org.eclipse.xtext</groupId>
								<artifactId>org.eclipse.xtext.xtext.generator</artifactId>
								<version>${xtext.version}</version>
							</dependency>
							<dependency>
								<groupId>org.eclipse.xtext</groupId>
								<artifactId>org.eclipse.xtext.xbase</artifactId>
								<version>${xtext.version}</version>
							</dependency>
							<dependency>
								<groupId>org.eclipse.xtext</groupId>
								<artifactId>xtext-antlr-generator</artifactId>
								<version>${xtext-antler-version}</version>
							</dependency>
							<dependency>
								<groupId>org.eclipse.xtext</groupId>
								<artifactId>org.eclipse.xtext.ecore</artifactId>
								<version>${xtext.version}</version>
							</dependency>
						</dependencies>
					</plugin>


The plugin is successfully executed, and in the maven logs I can see that it tries to generate the code for the correct model file:

EcoreGenerator     - generating EMF code for /tmp/generator/code/com.project.name.workflow/../com.project.name.expr/model/IdlExpr.genmodel


But this throws several IOExceptions, because the following files are unmapped (in the com.project.name.expr project):


  • plugin.properties
  • build.properties
  • META-INF/MANIFEST.mf
  • plugin.xml


How could we resolve this issue?
Re: Separate workflow project for emf code generation [message #1796989 is a reply to message #1796960] Tue, 23 October 2018 15:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30693
Registered: July 2009
Senior Member
According to https://projects.eclipse.org/projects/modeling.emf.mwe/contact it's probably better t o use the EMFT forum. But I'm at EclipseCon Europe so I'll ask them if they could have a look here...
Re: Separate workflow project for emf code generation [message #1796995 is a reply to message #1796989] Tue, 23 October 2018 16:32 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6538
Registered: July 2009
Senior Member
Hi

For OCL I aggregate multiple workflows in a an aggregate workflow. See http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/GenerateAll.mwe2

But re-use of variable names is dangerous., since all initializations occur first then workflows execute. Consequently the initialization for a multiple workflow may be more 'generous' / 'corrupted' compared to a single workflow. Also there is inadequate workflow scoping of variables, so you may want to use distinct names in each workflow rather than "resourceSet" everywhere.

I much prefer to launch manually when actually necessary from a launch config and commit the tested results to GIT for Java builds. Xtext lacks the requisite forward/backward compatibility to allow mindless automatic regeneration of Xtext artefacts; they must be manually approved/worked around before publication. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=460978

Debugging exceptions that only occur within the more challenging/less debuggable Maven environment seems like a waste of time.

Regards

Ed Willink
Previous Topic:Concurrent reads after full resource traversal
Next Topic:How to properly limit net4j's thread pool
Goto Forum:
  


Current Time: Sun Dec 15 19:17:33 GMT 2019

Powered by FUDForum. Page generated in 0.01505 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top