Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin?
icon5.gif  How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1192250] Sun, 17 November 2013 13:08 Go to next message
Torsten Juergeleit is currently offline Torsten JuergeleitFriend
Messages: 18
Registered: July 2009
Junior Member
The Xtext news Full Maven Support Coming With Version 2.5 on December 11th states:

Quote:
... It will include a new Maven Plug-In for easy execution of your languages and code generators within a Maven build. Also the jars needed for execution will be available through Maven central. ...

Creating Maven artifacts from Eclipse OSGi bundles to run an Xtext-based code generator from within a Maven plugin is right now a major PITA.

Now I'm wondering how to use this new "Full Maven Support" in our own Xtext-based code generator Maven plugin Sculptor Code Generator.

/Torsten
Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1200693 is a reply to message #1192250] Thu, 21 November 2013 11:08 Go to previous messageGo to next message
Annette Pohl is currently offline Annette PohlFriend
Messages: 9
Registered: July 2011
Junior Member
Hi,
we are looking for a short description how to use this xtext maven plugin, too.
Could you please give some hints?

Thanks
Annette


Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1202751 is a reply to message #1192250] Fri, 22 November 2013 09:45 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Torsten,

we are still testing (and changing).
For the release there will be documentation explaining who to do it.

For now just a brief overview:

Req: You build your Xtext language with Tycho (see e.g.
http://www.roperia.com/article/363/building-xtext-plugins-with-maven-and-tycho-a-step-by-step-guide)

Then you can use the generic Xtext plug-in like this :


<plugin>
<groupId>org.eclipse.xtext</groupId>
<artifactId>xtext-maven-plugin</artifactId>
<version>2.5.0-SNAPSHOT</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<languages>
<language>
<setup>my.mavenized.HeroLanguageStandaloneSetup</setup>
<outputConfigurations>
<outputConfiguration>
<outputDirectory>src/main/generated-sources/java/</outputDirectory>
</outputConfiguration>
</outputConfigurations>
</language>
</languages>
</configuration>
<dependencies>
<!-- the dependencies to the used languages -->
<dependency>
<groupId>my.mavenized.herolanguage</groupId>
<artifactId>my.mavenized.herolanguage</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>


I have also managed to do the code generation of the Xtext language
itself (i.e. from the grammar) in maven and will write something about
that as well.

Sven

Am 11/17/13 2:08 PM, schrieb Torsten Juergeleit:
> The Xtext news
> http://xtextnews.blogspot.de/2013/11/full-maven-support-coming-with-version.html
> states:
>
> Quote:
>> ... It will include a new Maven Plug-In for easy execution of your
>> languages and code generators within a Maven build. Also the jars
>> needed for execution will be available through Maven central. ...
>
> Creating Maven artifacts from Eclipse OSGi bundles to run an Xtext-based
> code generator from within a Maven plugin is right now a major PITA.
>
> Now I'm wondering how to use this new "Full Maven Support" in our own
> Xtext-based code generator Maven plugin http://sculptorgenerator.org/.
>
> /Torsten


--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1203191 is a reply to message #1202751] Fri, 22 November 2013 14:26 Go to previous messageGo to next message
Annette Pohl is currently offline Annette PohlFriend
Messages: 9
Registered: July 2011
Junior Member
Hi Sven,

thanks for your answer.
We have tried your approach and ran into several problems:

- We did not find version 2.5.0 in maven central. But we built it locally. Or does version 2.4.3 work as well (which is in maven central)?

- We are quite sure that our generator was never called. Can we enable debug as log level of the xtext maven plugin somehow in order to see what is going wrong?

Our plugin config looks like this:


<plugin>
	<groupId>org.eclipse.xtext</groupId>
	<artifactId>xtext-maven-plugin</artifactId>
	<version>2.5.0-SNAPSHOT</version>
	<executions>
		<execution>
			<phase>generate-sources</phase>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<compilerSourceLevel>1.7</compilerSourceLevel>
		<compilerTargetLevel>1.7</compilerTargetLevel>
		<languages>
			<language>
				<setup>com.codespitter.dsl.idef.IDefDslStandaloneSetup</setup>
				<outputConfigurations>
					<outputConfiguration>
						<outputDirectory>./src/mvn/java/</outputDirectory>
						<createOutputDirectory>true</createOutputDirectory>
						<overrideExistingResources>true</overrideExistingResources>
						<cleanUpDerivedResources>true</cleanUpDerivedResources>
					</outputConfiguration>
				</outputConfigurations>
			</language>
		</languages>
	</configuration>
	<dependencies>
                ... some dependencies ...
	</dependencies>
</plugin>




We needed compilerSourceLevel and compilerTargetLevel because the default was 1.5.

Is it OK to set the additional properties in outputConfigurations?

Thanks.
Annette
Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1203216 is a reply to message #1202751] Fri, 22 November 2013 14:44 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
I've put together an example project :
https://github.com/svenefftinge/maven-xtext-example

hth,
sven

--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de
Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1203345 is a reply to message #1203216] Fri, 22 November 2013 16:01 Go to previous messageGo to next message
Annette Pohl is currently offline Annette PohlFriend
Messages: 9
Registered: July 2011
Junior Member
Thanks
I am going to take a closer look on Monday.
Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1204081 is a reply to message #1203216] Sat, 23 November 2013 00:30 Go to previous messageGo to next message
Michael Vorburger is currently offline Michael VorburgerFriend
Messages: 103
Registered: July 2009
Senior Member
I've just tried this out, and proposed pull requests for a few minor and one critical problem: https://github.com/svenefftinge/maven-xtext-example/pull/3

Also, anyone wants to vote for https://bugs.eclipse.org/bugs/show_bug.cgi?id=422375 ? Wink
Re: How to use Xtext 2.5 new Full Maven Support in own code generator shipped as maven plugin? [message #1219859 is a reply to message #1204081] Fri, 06 December 2013 10:17 Go to previous message
Annette Pohl is currently offline Annette PohlFriend
Messages: 9
Registered: July 2011
Junior Member
Hi Sven,

thanks for the example. It is working now.
The problem was that our dsl files are located in src/main/resources and the generator did not find them. We added the following lines to our pom and now everything is fine.

					<sourceRoots>
						<sourceRoot>${basedir}/src/main/resources</sourceRoot>
						<sourceRoot>${basedir}/src/main/java</sourceRoot>
						<sourceRoot>${basedir}/src/gen/java</sourceRoot>
					</sourceRoots>


Kind regards
Annette
Previous Topic:ILocationInFileProvider Fails to Get Correct Position
Next Topic:Trouble emitting template code after splitting Generator Xtend into two pieces
Goto Forum:
  


Current Time: Thu Apr 18 15:46:35 GMT 2024

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

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

Back to the top