Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generation of model files with Maven(How to generate target files out of model files with Maven?)
icon5.gif  Generation of model files with Maven [message #1225627] Mon, 30 December 2013 10:32 Go to next message
Adrian Pollak is currently offline Adrian PollakFriend
Messages: 27
Registered: August 2013
Junior Member
Hello,

these are steps how I use XText:
1. I have created a valid grammar "UseCaseTypeModel.xtext". There are no problems with generating the artifacts under Eclipse.
2. I have "GenerateUseCaseTypeModel.mwe2" File. Also no problems with generating the MWE2 workflow via Eclipse.

Extraction from File "GenerateUseCaseTypeModel.mwe2":
var grammarURI = "classpath:/com/ourPackage/dsl/UseCaseTypeModel.xtext"
var fileExtensions = "bm,def"
var projectName = "com.ourPackage.dsl"
var runtimeProject = "../${projectName}"
var generateXtendStub = true

3. Launching the generated IDE Plug-in is also flawless.
4. Creating model files with defined file extensions (bm,def) with IDE assistance is also possible.
5. Generating the target files through an eclipse build of the model files (bm,def) is also correct.

So the manual way over Eclipse works as desired.

The main problem is the full automated way via a Maven build.
The steps 1. + 2. (see first code snippet) are already done and operate correct (using Tycho; offline mode is also ok).

This is the related pom.xml
...
<parent>
	<relativePath>../com.ourPackage.releng/pom.xml</relativePath>
	<groupId>com.ourPackage</groupId>
	<artifactId>parent</artifactId>
	<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>com.ourPackage.dsl</artifactId>
<packaging>eclipse-plugin</packaging>
<name>DSL Definition (com.ourPackage.dsl)</name>
<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<repositories>
...
</repositories>
<pluginRepositories>
	<!-- Repository to resolve fornax-oaw-m2-plugin -->
	<pluginRepository>
		<id>fornax.plugin.repository</id>
		<name>Fornax Plugin Repository</name>
		<url>fornax-platform</url>
	</pluginRepository>
</pluginRepositories>
<build>
	<resources>
		<resource>
			<directory>src</directory>
			<includes>
				<include>**/*.xtext</include>
			</includes>
		</resource>
	</resources>
	<plugins>
		<plugin>
			<groupId>org.codehaus.mojo</groupId>
			<artifactId>build-helper-maven-plugin</artifactId>
			<version>1.8</version>
			<executions>
				<execution>
					<id>add-source</id>
					<phase>generate-sources</phase>
					<goals>
							<goal>add-source</goal>
					</goals>
					<configuration>
						<sources>
							<source>src-gen</source>
							<source>src</source>
							<source>xtend-gen</source>
						</sources>
					</configuration>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<groupId>org.eclipse.tycho</groupId>
			<artifactId>tycho-maven-plugin</artifactId>
			<extensions>true</extensions>
			<version>0.19.0</version>
		</plugin>
		<plugin>
			<groupId>org.fornax.toolsupport</groupId>
			<artifactId>fornax-oaw-m2-plugin</artifactId>
			<version>3.4.0</version>
			<configuration>
				<workflowEngine>mwe2</workflowEngine>
				<workflowDescriptor>src/com/ourPackage/dsl/GenerateUseCaseTypeModel.mwe2</workflowDescriptor>
			</configuration>
			<executions>
				<execution>
					<phase>generate-sources</phase>
					<goals>
						<goal>run-workflow</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<groupId>org.eclipse.xtend</groupId>
			<artifactId>xtend-maven-plugin</artifactId>
			<version>2.5.0</version>
			<executions>
				<execution>
					<phase>generate-sources</phase>
					<goals>
						<goal>compile</goal>
					</goals>
					<configuration>
						<outputDirectory>xtend-gen</outputDirectory>
					</configuration>
				</execution>
			</executions>
		</plugin>
		<plugin>
			<artifactId>maven-clean-plugin</artifactId>
			<version>2.4.1</version>
			<configuration>
				<filesets>
					<fileset>
						<directory>src-gen</directory>
						<includes>
							<include>**</include>
						</includes>
					</fileset>
					<fileset>
						<directory>src/main</directory>
						<includes>
							<include>**/**</include>
						</includes>
					</fileset>
					<fileset>
						<directory>xtend-gen</directory>
						<includes>
							<include>**/**</include>
						</includes>
					</fileset>
				</filesets>
			</configuration>
		</plugin>
	</plugins>
</build>


But what has to be done are the steps 4. + 5.
Is there something like a Maven goal to generate the target files out of the model files?


Although I'm not sure I'm going into the right direction I tried the following solution without success:
http://www.eclipse.org/forums/index.php/t/602210/

This is the related pom.xml:
...
<parent>
	<relativePath>../com.ourPackage.releng/pom.xml</relativePath>
	<groupId>com.ourPackage</groupId>
	<artifactId>parent</artifactId>
	<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>com.ourPackage.bam</artifactId>
<packaging>eclipse-plugin</packaging>

<name>DSL Generation (com.ourPackage.bam)</name>

<properties>
	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>


<repositories>
...
</repositories>

<pluginRepositories>
	<pluginRepository>
		<id>fornax.plugin.repository</id>
		<name>Fornax Plugin Repository</name>
		<url>fornax-platform</url>
	</pluginRepository>
</pluginRepositories>


<build>
	<resources>
		<resource>
			<directory>src</directory>
			<includes>
				<include>**/*.bm</include>
			</includes>
		</resource>
	</resources>
	
	
	<plugins>

		<plugin>
			<groupId>org-eclipse-tycho</groupId>
			<artifactId>tycho-maven-plugin</artifactId>
			<extensions>true</extensions>
			<version>0.19.0</version>
		</plugin>


		<plugin>
			<groupId>org-eclipse-xtext</groupId>
			<artifactId>xtext-maven-plugin</artifactId>
			<version>2.5.0</version>

			<executions>
				<execution>
					<goals>
						<goal>generate</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<compilerSourceLevel>1.6</compilerSourceLevel>
				<compilerTargetLevel>1.6</compilerTargetLevel>
	
				<sourceRoots>
					<sourceRoot>src/com/ourPackage/bm</sourceRoot>
				</sourceRoots>
			
				<languages>
					<language>
						<setup>com.ourPackage.dsl.UseCaseTypeModelStandaloneSetup</setup>
						<outputConfigurations>
							<outputConfiguration>
								<outputDirectory>generateTo/</outputDirectory>
								<createOutputDirectory>true</createOutputDirectory>
					      <overrideExistingResources>true</overrideExistingResources>
					      <cleanUpDerivedResources>true</cleanUpDerivedResources>
							</outputConfiguration>
						</outputConfigurations>
					</language>
				</languages>
			</configuration>


			<dependencies>
				<dependency>
					<groupId>com.ourPackage</groupId>
					<artifactId>com.ourPackage.dsl</artifactId>
					<version>1.0.0-SNAPSHOT</version>
				</dependency>
			</dependencies>
		</plugin>
	</plugins>
</build>


Any help is appreciated.
Thank you!

Regards

Adrian



By the way. With this restriction:
"You can only use links to eclipse.org sites while you have fewer than 5 messages."
it is very difficult to post correct and complete code snippets! Crying or Very Sad

[Updated on: Mon, 30 December 2013 10:43]

Report message to a moderator

Re: Generation of model files with Maven [message #1225646 is a reply to message #1225627] Mon, 30 December 2013 11:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
do you get any error message?
did you check svens code from github?
can you share your code?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generation of model files with Maven [message #1225666 is a reply to message #1225646] Mon, 30 December 2013 12:57 Go to previous messageGo to next message
Adrian Pollak is currently offline Adrian PollakFriend
Messages: 27
Registered: August 2013
Junior Member
Thank you for the quick reply. Smile

No, there was no error message within my project.
Unfortunately, none of the expected target files is created (out of the *.bm model files).

So I'm unsure that I use the right approach. Do I?

In Svens example there is a model file "Super.hero" (maven-xtext-example/example-project/src/main/java/)
But I could not see that this example project is part of the parent project (releng).
My expectation is that a java class is generated out of the model file through a Maven build. Is this correct?

When I try to execute Svens example I get the following error:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] My Hero Language Core
[INFO] My Hero Language UI
[INFO] My Hero Language Tests
[INFO] My Hero Language Feature
[INFO] My Hero Language Update Site
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building parent 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent ---
[INFO] Installing C:\workspaces\maven-xtext-example-master\my.mavenized.herolanguage.releng\pom.xml to C:\applications\maven-repository3\my\mavenized\
herolanguage\parent\1.0.0-SNAPSHOT\parent-1.0.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building My Hero Language Core 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my.mavenized.herolanguage ---
[INFO]
[INFO] --- tycho-packaging-plugin:0.19.0:build-qualifier (default-build-qualifier) @ my.mavenized.herolanguage ---
[INFO] The project's OSGi version is 1.0.0.201312301229
[INFO]
[INFO] --- tycho-packaging-plugin:0.19.0:validate-id (default-validate-id) @ my.mavenized.herolanguage ---
[INFO]
[INFO] --- tycho-packaging-plugin:0.19.0:validate-version (default-validate-version) @ my.mavenized.herolanguage ---
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default) @ my.mavenized.herolanguage >>>
[INFO]
[INFO] --- tycho-packaging-plugin:0.19.0:build-qualifier (default-build-qualifier) @ my.mavenized.herolanguage ---
[INFO] The project's OSGi version is 1.0.0.201312301229
[INFO]
[INFO] --- tycho-packaging-plugin:0.19.0:validate-id (default-validate-id) @ my.mavenized.herolanguage ---
[INFO]
[INFO] --- tycho-packaging-plugin:0.19.0:validate-version (default-validate-version) @ my.mavenized.herolanguage ---
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default) @ my.mavenized.herolanguage <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default) @ my.mavenized.herolanguage ---
Downloading: nexus.codehaus.org/snapshots/org/eclipse/xtext/org-eclipse-xtext.xtext/2.5.0-SNAPSHOT/maven-metadata.xml
Downloading: snapshots.repository.codehaus.org/org/eclipse/xtext/org-eclipse-xtext.xtext/2.5.0-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xtext:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus.org (snapsho
ts.repository.codehaus.org): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
[WARNING] Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xtext:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus-snapshots (n
exus.codehaus.org/snapshots/): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
[WARNING] Failure to transfer org-eclipse-xtext:org-eclipse-xtext.xtext:2.5.0-SNAPSHOT/maven-metadata.xml from snapshots.repository.codehaus.or
g was cached in the local repository, resolution will not be reattempted until the update interval of codehaus.org has elapsed or updates are forced.
Original error: Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xtext:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus.org (s
napshots.repository.codehaus.org): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
[WARNING] Failure to transfer org-eclipse-xtext:org-eclipse-xtext.xtext:2.5.0-SNAPSHOT/maven-metadata.xml from nexus.codehaus.org/snapshots/ wa
s cached in the local repository, resolution will not be reattempted until the update interval of codehaus-snapshots has elapsed or updates are forced
. Original error: Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xtext:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus-snapshots (
nexus.codehaus.org/snapshots/): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
Downloading: snapshots.repository.codehaus.org/org/eclipse/xtext/org-eclipse-xtext.xtext/2.5.0-SNAPSHOT/org-eclipse-xtext.xtext-2.5.0-SNAPSHOT.
pom
Downloading: nexus.codehaus.org/snapshots/org/eclipse/xtext/org-eclipse-xtext.xtext/2.5.0-SNAPSHOT/org-eclipse-xtext.xtext-2.5.0-SNAPSHOT.pom
Downloading: nexus.codehaus.org/snapshots/org/eclipse/xtext/org-eclipse-xtext.xbase/2.5.0-SNAPSHOT/maven-metadata.xml
Downloading: snapshots.repository.codehaus.org/org/eclipse/xtext/org-eclipse-xtext.xbase/2.5.0-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xbase:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus.org (snapsho
ts.repository.codehaus.org): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
[WARNING] Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xbase:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus-snapshots (n
exus.codehaus.org/snapshots/): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
[WARNING] Failure to transfer org-eclipse-xtext:org-eclipse-xtext.xbase:2.5.0-SNAPSHOT/maven-metadata.xml from snapshots.repository.codehaus.or
g was cached in the local repository, resolution will not be reattempted until the update interval of codehaus.org has elapsed or updates are forced.
Original error: Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xbase:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus.org (s
napshots.repository.codehaus.org): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
[WARNING] Failure to transfer org-eclipse-xtext:org-eclipse-xtext.xbase:2.5.0-SNAPSHOT/maven-metadata.xml from nexus.codehaus.org/snapshots/ wa
s cached in the local repository, resolution will not be reattempted until the update interval of codehaus-snapshots has elapsed or updates are forced
. Original error: Could not transfer metadata org-eclipse-xtext:org-eclipse-xtext.xbase:2.5.0-SNAPSHOT/maven-metadata.xml from/to codehaus-snapshots (
nexus.codehaus.org/snapshots/): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required.
Downloading: snapshots.repository.codehaus.org/org/eclipse/xtext/org-eclipse-xtext.xbase/2.5.0-SNAPSHOT/org-eclipse-xtext.xbase-2.5.0-SNAPSHOT.
pom
Downloading: nexus.codehaus.org/snapshots/org/eclipse/xtext/org-eclipse-xtext.xbase/2.5.0-SNAPSHOT/org-eclipse-xtext.xbase-2.5.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.197s]
[INFO] My Hero Language Core ............................. FAILURE [0.839s]
[INFO] My Hero Language UI ............................... SKIPPED
[INFO] My Hero Language Tests ............................ SKIPPED
[INFO] My Hero Language Feature .......................... SKIPPED
[INFO] My Hero Language Update Site ...................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:00.259s
[INFO] Finished at: Mon Dec 30 13:29:48 CET 2013
[INFO] Final Memory: 54M/165M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default) on project my.mavenized.herolanguage: Execution default of goa
l org.codehaus.mojo:exec-maven-plugin:1.2.1:java failed: Plugin org.codehaus.mojo:exec-maven-plugin:1.2.1 or one of its dependencies could not be reso
lved: Failed to collect dependencies for org.codehaus.mojo:exec-maven-plugin:jar:1.2.1 (): Failed to read artifact descriptor for org-eclipse-xtext:or
g-eclipse-xtext.xtext:jar:2.5.0-SNAPSHOT: Could not transfer artifact org-eclipse-xtext:org-eclipse-xtext.xtext:pom:2.5.0-SNAPSHOT from/to codehaus.or
g (snapshots.repository.codehaus.org): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :my.mavenized.herolanguage
C:\workspaces\maven-xtext-example-master\my.mavenized.herolanguage.releng>


Regards

Adrian
Re: Generation of model files with Maven [message #1225667 is a reply to message #1225666] Mon, 30 December 2013 13:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i think the version should be without -SNAPSHOT now.
never the less i just built a own example (not yet cleaned up)
https://github.com/cdietrich/xtext-maven-example



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generation of model files with Maven [message #1225685 is a reply to message #1225667] Mon, 30 December 2013 14:02 Go to previous message
Adrian Pollak is currently offline Adrian PollakFriend
Messages: 27
Registered: August 2013
Junior Member
Hello Christian,

I downloaded your example and everything works fine.

The 'greetings.txt' file with the expected content was created in the folder /target/model-gen.

Through your example I'm confident that I'm on the right path.

Thank you very much!

Best regards

Adrian
Previous Topic:Writing the contents of xtext editor to some other view
Next Topic:How to load and parse a language file inside an OSGi bundle
Goto Forum:
  


Current Time: Thu Mar 28 21:57:45 GMT 2024

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

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

Back to the top