Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Maven build from existing .ecore/.genmodel?
Maven build from existing .ecore/.genmodel? [message #1814110] Tue, 03 September 2019 19:29 Go to next message
Eclipse UserFriend
Hi all,

I'm resurrecting an old xtext project. My strategy is to use the tooling to create a new one (using the latest version of Xtext), then copy the existing dsl (*.xtext file) source into the new project. Everything is looking pretty good, but it appears that the maven pom files are not generating Java sources from the .ecore/.genmodel files.

I'm deducing this because when I generate from the IDE (open .genmodel, expand root node, right click on first node, then "Generate Model Sources"), then go to the command line and run just "mvn package", it builds ok. However, if I issue "mvn clean package", the build fails because the Java EMF files are not being generated.

How do I configure my pom to generate Java EMF sources during the generate-sources phase? The existing pom is pretty much exactly as it was generated by the eclipse project creation wizard. Portion of pom.xml:
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>exec-maven-plugin</artifactId>
				<version>1.4.0</version>
				<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.basedir}/src/io/yaktor/dsl/domain/GenerateDomain.mwe2</argument>
						<argument>-p</argument>
						<argument>rootPath=/${project.basedir}/..</argument>
					</arguments>
					<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>2.10.0</version>
					</dependency>
					<dependency>
						<groupId>org.eclipse.xtext</groupId>
						<artifactId>org.eclipse.xtext.common.types</artifactId>
						<version>${xtextVersion}</version>
					</dependency>
					<dependency>
						<groupId>org.eclipse.xtext</groupId>
						<artifactId>org.eclipse.xtext.xtext.generator</artifactId>
						<version>${xtextVersion}</version>
					</dependency>
					<dependency>
						<groupId>org.eclipse.xtext</groupId>
						<artifactId>org.eclipse.xtext.xbase</artifactId>
						<version>${xtextVersion}</version>
					</dependency>
					<dependency>
						<groupId>org.eclipse.xtext</groupId>
						<artifactId>xtext-antlr-generator</artifactId>
						<version>2.1.1</version>
					</dependency>
				</dependencies>
			</plugin>
			<plugin>
				<groupId>org.eclipse.xtend</groupId>
				<artifactId>xtend-maven-plugin</artifactId>
			</plugin>


Thanks,
Matthew
Re: Maven build from existing .ecore/.genmodel? [message #1814114 is a reply to message #1814110] Wed, 04 September 2019 02:26 Go to previous messageGo to next message
Eclipse UserFriend
The pom.xml looks as I would expect. This should launch the GenerateDomain.mwe2 generator workflow during the generate-sources phase. Within that workflow the EMF sources should be generated from the genmodel using the org.eclipse.emf.mwe2.ecore.EcoreGenerator component.
Re: Maven build from existing .ecore/.genmodel? [message #1814139 is a reply to message #1814114] Wed, 04 September 2019 11:57 Go to previous messageGo to next message
Eclipse UserFriend
Ok, but it's not happening:
$ mvn clean package
...
[INFO] -------------< io.yaktor.dsl.domain:io.yaktor.dsl.domain >--------------
[INFO] Building io.yaktor.dsl.domain 1.0.0-SNAPSHOT
[INFO] ---------------------------[ eclipse-plugin ]---------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ io.yaktor.dsl.domain ---
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/target
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/xtend-gen (includes = [**/*], excludes = [])
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/../io.yaktor.dsl.domain/src-gen (includes = [**/*], excludes = [])
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/../io.yaktor.dsl.domain.tests/src-gen (includes = [**/*], excludes = [])
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/../io.yaktor.dsl.domain.ide/src-gen (includes = [**/*], excludes = [])
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/../io.yaktor.dsl.domain.ui/src-gen (includes = [**/*], excludes = [])
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/../io.yaktor.dsl.domain.ui.tests/src-gen (includes = [**/*], excludes = [])
[INFO] Deleting /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/../io.yaktor.dsl.domain.web/src-gen (includes = [**/*], excludes = [])
[INFO]
[INFO] --- tycho-packaging-plugin:1.4.0:build-qualifier (default-build-qualifier) @ io.yaktor.dsl.domain ---
[INFO] The project's OSGi version is 1.0.0.201909032314
[INFO]
[INFO] --- tycho-packaging-plugin:1.4.0:validate-id (default-validate-id) @ io.yaktor.dsl.domain ---
[INFO]
[INFO] --- tycho-packaging-plugin:1.4.0:validate-version (default-validate-version) @ io.yaktor.dsl.domain ---
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (mwe2Launcher) @ io.yaktor.dsl.domain ---
0    INFO  XtextGenerator     - Initializing Xtext generator
Sep 03, 2019 4:14:57 PM org.eclipse.emf.mwe.utils.StandaloneSetup addRegisterGeneratedEPackage
INFO: Adding generated EPackage 'org.eclipse.xtext.common.types.TypesPackage'
Sep 03, 2019 4:14:57 PM org.eclipse.emf.mwe.utils.StandaloneSetup registerMapping
...
INFO: Using resourceSet registry. The registered Packages will not be registered in the global EPackage.Registry.INSTANCE!
Sep 03, 2019 4:14:58 PM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFO: Registered GenModel 'http://www.eclipse.org/Xtext/Xbase/XAnnotations' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
Sep 03, 2019 4:14:58 PM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFO: Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xtype' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
Sep 03, 2019 4:14:58 PM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFO: Registered GenModel 'http://www.eclipse.org/xtext/xbase/Xbase' from 'platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel'
Sep 03, 2019 4:14:58 PM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFO: Registered GenModel 'http://www.eclipse.org/xtext/common/JavaVMTypes' from 'platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel'
Sep 03, 2019 4:14:58 PM org.eclipse.emf.mwe.utils.GenModelHelper registerGenModel
INFO: Registered GenModel 'http://www.yaktor.io/dsl/domain' from 'platform:/resource/io.yaktor.dsl.domain/model/domain.genmodel'
1139 INFO  XtextGenerator     - Generating io.yaktor.dsl.domain.Domain
7503 INFO  XtextGenerator     - Generating common infrastructure
7516 INFO  Workflow           - Done.
[INFO]
[INFO] --- xtend-maven-plugin:2.18.0:compile (default) @ io.yaktor.dsl.domain ---
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ io.yaktor.dsl.domain ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/src/main/resources
[INFO]
[INFO] --- tycho-compiler-plugin:1.4.0:compile (default-compile) @ io.yaktor.dsl.domain ---
[INFO] Compiling 17 source files to /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  36.229 s
[INFO] Finished at: 2019-09-03T16:15:10-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.4.0:compile (default-compile) on project io.yaktor.dsl.domain: Compilation failure: Compilation failure:
[ERROR] /Users/matthewadams/dev/yaktor/yaktor-dsl-xtext/io.yaktor.dsl.domain.parent/io.yaktor.dsl.domain/src-gen/io/yaktor/dsl/domain/serializer/DomainSemanticSequencer.java:[7]
[ERROR] 	import io.yaktor.dsl.domain.ecore.domain.AmountField;
[ERROR] 	       ^^^^^^^^^^^^^^^^^^^^^^^^^^
...
$ ls -al src-gen/io/yaktor/dsl/domain/ # no ecore folder!
total 64
drwxr-xr-x  10 matthewadams  staff    320 Sep  3 16:15 .
drwxr-xr-x   3 matthewadams  staff     96 Sep  3 16:15 ..
-rw-r--r--   1 matthewadams  staff   9323 Sep  3 16:15 AbstractDomainRuntimeModule.java
-rw-r--r--   1 matthewadams  staff  13075 Sep  3 16:15 Domain.xtextbin
-rw-r--r--   1 matthewadams  staff   1194 Sep  3 16:15 DomainStandaloneSetupGenerated.java
drwxr-xr-x   3 matthewadams  staff     96 Sep  3 16:15 parser
drwxr-xr-x   3 matthewadams  staff     96 Sep  3 16:15 scoping
drwxr-xr-x   4 matthewadams  staff    128 Sep  3 16:15 serializer
drwxr-xr-x   3 matthewadams  staff     96 Sep  3 16:15 services
drwxr-xr-x   4 matthewadams  staff    128 Sep  3 16:15 validation

Class io.yaktor.dsl.domain.ecore.domain.AmountField is a defined in file model/domain.ecore. When I look in target/classes, there are no classes in io/yaktor/dsl/domain/ecore/domain. Here is my .mwe2 file:
module io.yaktor.dsl.domain.GenerateDomain

import org.eclipse.xtext.xtext.generator.*
import org.eclipse.xtext.xtext.generator.model.project.*

var rootPath = ".."

Workflow {
	
	component = XtextGenerator {
		configuration = {
			project = StandardProjectConfig {
				baseName = "io.yaktor.dsl.domain"
				rootPath = rootPath
				runtimeTest = {
					enabled = true
				}
				eclipsePlugin = {
					enabled = true
				}
				eclipsePluginTest = {
					enabled = true
				}
				web = {
					enabled = true
				}
				createEclipseMetaData = true
				genericIde = {
					enabled = true
				}
			}
			code = {
				encoding = "UTF-8"
				lineDelimiter = "\n"
				fileHeader = "/*\n * generated by Xtext \${version}\n */"
			}
		}
		language = StandardLanguage {
			name = "io.yaktor.dsl.domain.Domain"
			fileExtensions = "ydm"
			referencedResource = "platform:/resource/io.yaktor.dsl.domain/model/domain.genmodel"
			
			serializer = {
				generateStub = false
			}
			validator = {
				// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
				generateDeprecationValidation = true
			}
			junitSupport = {
				junitVersion = "5"
			}
		}
	}
}


Anyone have any tips here?
Re: Maven build from existing .ecore/.genmodel? [message #1814140 is a reply to message #1814139] Wed, 04 September 2019 12:40 Go to previous messageGo to next message
Eclipse UserFriend
where is your EcoreGenerator component in the workflow?
Re: Maven build from existing .ecore/.genmodel? [message #1814143 is a reply to message #1814140] Wed, 04 September 2019 13:22 Go to previous messageGo to next message
Eclipse UserFriend
Obviously, not present. :P

Recall, however, that I'm not generating my EMF .ecore/.genmodel. I'm using my own .ecore & .genmodel file (although I feel like the .genmodel file could be generated from the .ecore file, but that's another story).

Do I need to add an EcoreGenerator to my workflow in this scenario?
Re: Maven build from existing .ecore/.genmodel? [message #1814145 is a reply to message #1814143] Wed, 04 September 2019 13:44 Go to previous message
Eclipse UserFriend
I added
	component = EcoreGenerator {
		genModel = "platform:/resource/io.yaktor.dsl.domain/model/domain.genmodel"
		srcPath = "platform:/resource/io.yaktor.dsl.domain/src-gen"
	}

to my .mwe2 (after the XtextGenerator, thank you https://www.eclipse.org/forums/index.php?t=msg&th=1095261&goto=1795421&#msg_1795421 very much), and everything is working like a charm.
Previous Topic:How to hide part of text in xtext editor
Next Topic:Cannot create resource...A Registered resource factory is needed
Goto Forum:
  


Current Time: Mon Apr 14 17:34:38 EDT 2025

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

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

Back to the top