Karsten's Blog

August 18, 2010

Building Xtext projects with Maven Tycho

Filed under: M2T, Maven, Xtext — kthoms @ 9:19 PM

Last year I showed how Xtext 0.7.2 projects can be build with Maven. It requires the installation of all related plugins as Maven artifacts in a Maven2 repository, which is a rather hard and error prone task. I was asked many times since then whether I would install Xtext 1.0 artifacts or even milestone versions into the openArchitectureWare Maven2 repository. Although I can really understand this requirement my hope was that I could avoid this and show a way to enable the build with Maven Tycho. Now the time has come that Tycho is mature enough and finally I had the time to do the necessary extension for the Fornax Maven Workflow Plugin to support the recently added MWE2 workflow engine, which is used from Xtext now as default. Maven Tycho and the Fornax plugin will allow to build Xtext projects in the most natural way possible.

A basic requirement for software builds is that everything can be build just from the sources. Also it is a good practice that no generated sources are checked in into a source repository. Unfortunately this often does not hold for Xtext projects, since it is a quite hard task to execute the Xtext generator in a build process. Yes, it is possible, but until now users often have to solve it again and again. Search the net, most projects seen there will just check in all the sources. The Fornax plugin and Maven will standardize this behavior.

What do you need to enable Xtext DSL builds with Tycho? Not much. Basically a Maven 3 installation (the beta is enough) and access to the internet to access the public repositories. A better idea is to use a repository manager in the intranet (like Nexus) to act as proxy for the public repositories. You will have to add some POMs to your projects. That’s it.

I’ll show now how to enable the basic project that you get from the Xtext project wizard get build with Maven Tycho.

1. Install Maven 3

Download Maven 3 from Apache, unpack it and put the bin folder on your path. Check the installation by typing ‘mvn –version‘ in a shell. You should something like this:

mvn --version
Apache Maven 3.0-beta-1 (r935667; 2010-04-19 19:00:39+0200)
Java version: 1.6.0_20
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: de_DE, platform encoding: MacRoman
OS name: "mac os x" version: "10.5.8" arch: "x86_64" Family: "mac"

2. Create the Xtext project

Select in Eclipse File / New / Project / Xtext Project and leave all the defaults. The project name should be org.xtext.example.mydsl for this tutorial. The projects will be created and almost empty for now. The aim is to get everything build by just adding the POMs.

3. Adjust plugin manifests

With the default Manifests the build does not execute successfully. The build fails because it has problems to resolve the logging infrastructure. It is sufficient to add Import-Package entries to resolve SLF4J and Logback. Open the plugin Manifest of the org.xtext.example.mydsl project, go to the Dependencies page and add the following Imported Packages:

  • ch.qos.logback.classic
  • ch.qos.logback.core.joran.spi
  • org.slf4j

For each of them open the Properties dialog and set the “optional” flag. Otherwise you could get problems when deploying these plugins. (Thanks to Christian Amman for this tip!)

Open the Manifest of org.xtext.example.mydsl.generator, add the same packages and additionally

  • org.apache.commons.logging

Again, set the imported packages to optional.

4. Add POM files

Each project will get a POM file. A Parent POM will contain the common settings and will act as a reactor POM also. Normally the Parent POM is placed in the directory above the modules, or here the plugin projects. This would be the workspace root. In this example we will place the Parent POM in the DSL grammar project. To make builds easier this POM will have the default name pom.xml. On the other side we have to add also a POM for the grammar project itself. Since it will be in the same directory we have to find another name, and we will call it pom-grammar.xml. For the other projects (.generator and .ui) we will stay with pom.xml.

4.1 org.xtext.example.mydsl/pom.xml

The Parent POM configures the Tycho plugins and aggregates the grammar project, UI project and the generator. Also the required repositories are configured here. Note that the folder “src” is added as resource path, this will add this folder to the classpath. The workflow execution would fail if the workflow module cannot be found on the classpath.

<!--?xml version="1.0" encoding="UTF-8"?-->
	4.0.0
	p2.osgi.bundle
	org.xtext.example.mydsl.parent
	1.0.0
	pom
	org.xtext.example.mydsl.MyDsl - Parent

		0.9.0

		./pom-grammar.xml
		../org.xtext.example.mydsl.ui
		../org.xtext.example.mydsl.generator

		<!-- The src directory must be named as resource dir to put it on the build classpath. This is required to resolve the 			workflow module named in the .mwe2 file -->

			src

				org.sonatype.tycho
				tycho-maven-plugin
				${version.tycho}
				true

				org.sonatype.tycho
				target-platform-configuration
				${version.tycho}

					p2

					org.fornax.toolsupport
					fornax-oaw-m2-plugin
					3.1.0-SNAPSHOT

						mwe2

							generate-sources
								run-workflow

			p2.eclipse.helios

http://download.eclipse.org/releases/helios

			p2

		<!-- At the moment the Fornax plugin is only available as snapshot -->

			fornax-snapshots

http://www.fornax-platform.org/archiva/repository/snapshots/

				false

				true

org.xtext.example.mydsl/pom-grammar.xml

The build of the grammar project needs to execute the workflow src/org/xtext/example/mydsl/GenerateMyDsl.mwe2. All other settings are already managed by the parent.

<!--?xml version="1.0" encoding="UTF-8"?-->
	4.0.0

		p2.osgi.bundle
		org.xtext.example.mydsl.parent
		1.0.0
		../org.xtext.example.mydsl/pom.xml

	org.xtext.example.mydsl
	eclipse-plugin
	org.xtext.example.mydsl.MyDsl - Grammar

				org.fornax.toolsupport
				fornax-oaw-m2-plugin

					src/org/xtext/example/mydsl/GenerateMyDsl.mwe2

org.xtext.example.mydsl.ui/pom.xml

The build configuration of the UI plugin is even easier. Only the reference to the parent and the minimum project coordinates need to be configured.

<!--?xml version="1.0" encoding="UTF-8"?-->
	4.0.0

		p2.osgi.bundle
		org.xtext.example.mydsl.parent
		1.0.0
		../org.xtext.example.mydsl/pom.xml

	org.xtext.example.mydsl.ui
	eclipse-plugin
	org.xtext.example.mydsl.MyDsl - UI

org.xtext.example.mydsl.generator/pom.xml

The generator plugin must execute its workflow. Note that the src directory and the compile directory of the grammar project are set as resource directory.

<!--?xml version="1.0" encoding="UTF-8"?-->
	4.0.0

		p2.osgi.bundle
		org.xtext.example.mydsl.parent
		1.0.0
		../org.xtext.example.mydsl/pom.xml

	org.xtext.example.mydsl.generator
	eclipse-plugin
	org.xtext.example.mydsl.MyDsl - Generator

			src
			<!-- Add the grammar classes to the classpath -->
			../org.xtext.example.mydsl/target/classes

				org.fornax.toolsupport
				fornax-oaw-m2-plugin

					mwe2
					src/workflow/MyDslGenerator.mwe2

5. Execute the build

Now the build should be executable. Run ‘mvn clean install‘ in the root of the org.xtext.example.mydsl project. Here is an excerpt of the console log you should get. The complete log can be viewed here.

mvn install
[INFO] Scanning for projects...
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Resolving target platform for project MavenProject: p2.osgi.bundle:org.xtext.example.mydsl:1.0.0 @ /Users/thoms/temp/tycho/trunk/trunk/org.xtext.example.mydsl/pom-grammar.xml
log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
log4j:WARN Please initialize the log4j system properly.
[INFO] Adding repository http://download.eclipse.org/releases/helios
[INFO] Adding repository http://download.eclipse.org/releases/helios
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Resolving target platform for project MavenProject: p2.osgi.bundle:org.xtext.example.mydsl.ui:1.0.0 @ /Users/thoms/temp/tycho/trunk/trunk/org.xtext.example.mydsl.ui/pom.xml
[INFO] Adding repository (cached) http://download.eclipse.org/releases/helios
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Resolving target platform for project MavenProject: p2.osgi.bundle:org.xtext.example.mydsl.generator:1.0.0 @ /Users/thoms/temp/tycho/trunk/trunk/org.xtext.example.mydsl.generator/pom.xml
[INFO] Adding repository (cached) http://download.eclipse.org/releases/helios
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] org.xtext.example.mydsl.MyDsl - Parent
[INFO] org.xtext.example.mydsl.MyDsl - Grammar
[INFO] org.xtext.example.mydsl.MyDsl - UI
[INFO] org.xtext.example.mydsl.MyDsl - Generator
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building org.xtext.example.mydsl.MyDsl - Parent 1.0.0
[INFO] ------------------------------------------------------------------------
....
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] org.xtext.example.mydsl.MyDsl - Parent ............ SUCCESS [0.681s]
[INFO] org.xtext.example.mydsl.MyDsl - Grammar ........... SUCCESS [26.418s]
[INFO] org.xtext.example.mydsl.MyDsl - UI ................ SUCCESS [3.103s]
[INFO] org.xtext.example.mydsl.MyDsl - Generator ......... SUCCESS [10.844s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

5. Miscalleneous

5.1 ANTLR 3 download

Xtext relies on ANTLR 3, which cannot be hosted at Eclipse.org due to incompatible licenses. Therefore Xtext has introduced an automatic download (FYI: This behavior is implemented in AntlrToolFacade) that you have to confirm once:

*ATTENTION*
It is recommended to use the ANTLR 3 parser generator (BSD licence - http://www.antlr.org/license.html).
Do you agree to download it (size 1MB) from 'http://download.itemis.com/antlr-generator-3.0.1.jar'? (type 'y' or 'n' and hit enter)

Now an automatic build is not so responsive to questions like these. The plugin will confirm this download automatically.

5.2 Workflow execution problems

If the Maven plugin does not execute the MWE2 workflow properly it is not so responsive at the moment to name the root cause. But when running the Maven command with “-X” it will output the full Java command including classpath to the console. Copy the full command and try to execute it from the same directory. This might help to detect the problem you have.

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java -classpath /Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.xpand/1.0.0.v201006150611/org.eclipse.xpand-1.0.0.v201006150611.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.xtend/1.0.0.v201006150611/org.eclipse.xtend-1.0.0.v201006150611.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.mwe.core/1.0.0.v201006150535/org.eclipse.emf.mwe.core-1.0.0.v201006150535.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.ecore/2.6.0.v20100614-1136/org.eclipse.emf.ecore-2.6.0.v20100614-1136.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.common/2.6.0.v20100614-1136/org.eclipse.emf.common-2.6.0.v20100614-1136.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.apache.commons.cli/1.0.0.v20080604-1500/org.apache.commons.cli-1.0.0.v20080604-1500.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.mwe2.runtime/1.0.0.v201006150446/org.eclipse.emf.mwe2.runtime-1.0.0.v201006150446.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/com.ibm.icu/4.2.1.v20100412/com.ibm.icu-4.2.1.v20100412.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.xtext/1.0.0.v201006170321/org.eclipse.xtext-1.0.0.v201006170321.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.ecore.xmi/2.5.0.v20100521-1846/org.eclipse.emf.ecore.xmi-2.5.0.v20100521-1846.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.xtext.util/1.0.0.v201006170321/org.eclipse.xtext.util-1.0.0.v201006170321.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/com.google.collect/0.8.0.v201006170321/com.google.collect-0.8.0.v201006170321.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/com.google.inject/2.0.0.v201003051000/com.google.inject-2.0.0.v201003051000.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.antlr.runtime/3.0.0.v200803061811/org.antlr.runtime-3.0.0.v200803061811.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.mwe.utils/1.0.0.v201006150535/org.eclipse.emf.mwe.utils-1.0.0.v201006150535.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.mwe2.launch/1.0.0.v201006150907/org.eclipse.emf.mwe2.launch-1.0.0.v201006150907.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.emf.mwe2.language/1.0.0.v201006150907/org.eclipse.emf.mwe2.language-1.0.0.v201006150907.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.xtext.common.types/1.0.0.v201006170321/org.eclipse.xtext.common.types-1.0.0.v201006170321.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.eclipse.xtend.typesystem.emf/1.0.0.v201006150611/org.eclipse.xtend.typesystem.emf-1.0.0.v201006150611.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/ch.qos.logback.classic/0.9.19.v20100519-1505/ch.qos.logback.classic-0.9.19.v20100519-1505.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/ch.qos.logback.core/0.9.19.v20100419-1216/ch.qos.logback.core-0.9.19.v20100419-1216.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.apache.commons.logging/1.1.1.v201005080502/org.apache.commons.logging-1.1.1.v201005080502.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.slf4j.api/1.5.11.v20100519-1910/org.slf4j.api-1.5.11.v20100519-1910.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/ch.qos.logback.slf4j/0.9.19.v20100519-1910/ch.qos.logback.slf4j-0.9.19.v20100519-1910.jar:/Users/thoms/.m2/repository/p2/osgi/bundle/org.slf4j.log4j/1.5.11.v20100419-1106/org.slf4j.log4j-1.5.11.v20100419-1106.jar org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher /Users/thoms/Development/workspaces/oaw-v5-test/org.xtext.example.mydsl.generator/src/workflow/MyDslGenerator.mwe2

5.3 Fornax Plugin Snapshot version

The Maven plugin org.fornax.toolsupport:fornax-oaw-m2-plugin is not released yet. Yesterday I have added the necessary support for MWE2 and deployed a snapshot version 3.1.0-SNAPSHOT. Some minor issues have to be solved before it will be released.

5.4 Missing log output

The plugin forks a JVM with help of the Java ant task type. At the moment the output from the forked JVM does not get redirected to the Plugin’s log. This is one issue to solve for the Plugin before release. It makes debugging problems a bit harder, but when copying the executed Java command that you get from the debug output and execute yourself you get a better impression of the error.

5.5 Download sources

For your convenience you can download the example project here.

About these ads

75 Comments »

  1. Great- just what I am looking for! :-)

    When do you think will the 3.1.0-SNAPSHOT version of the plugin be available? I really would like to test it. Or can you send it to me privately before official release?

    –Heiko

    Comment by Heiko Tappe — August 19, 2010 @ 9:25 AM

  2. Hi Karsten,

    thanks a lot for your example.

    One comment: maybe it is necessary to specify a pluginReposlitory like:

    fornax-snapshots
    http://www.fornax-platform.org/archiva/repository/snapshots

    false

    true

    Best regards,
    Martin

    Comment by Martin — August 19, 2010 @ 1:22 PM

    • Correct, added it. Just did not notice it since I install the snapshot plugin into my local repo.

      Thx,
      ~Karsten

      Comment by kthoms — August 19, 2010 @ 9:08 PM

  3. Oops. I didn’t know of the snapshots repository. Now I can run the plugin :-)

    But now running “mvn install” I get exactly the same output as the log above but it doesn’t seem to continue after

    [INFO] Fornax oAW/MWE/MWE2 Maven2 Plugin V3.1.0-SNAPSHOT

    The only difference I can see at first glance is the maven-3 version. I used beta2.

    Any idea?

    –Heiko

    Comment by Heiko Tappe — August 19, 2010 @ 3:34 PM

  4. OK, step by step ;-)

    The problem was the missing .antlr-generator-3.0.1.jar
    But I was never asked to download it!

    Now the (hopefully) last problem seems to be the generator project:

    [INFO] org.xtext.example.mydsl.MyDsl – Parent ………… SUCCESS [1.672s]
    [INFO] org.xtext.example.mydsl.MyDsl – Grammar ……….. SUCCESS [21.328s]
    [INFO] org.xtext.example.mydsl.MyDsl – UI ……………. SUCCESS [7.109s]
    [INFO] org.xtext.example.mydsl.MyDsl – Generator ……… FAILURE [5.594s]

    [ERROR] Failed to execute goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow (default) on project org.xtext.example.mydsl.generator: Generation failed -> [Help 1]

    Comment by Heiko Tappe — August 19, 2010 @ 4:22 PM

    • Hi Heiko!

      Yes, the download input as well as all other output from Xtext does not appear. I have to redirect the output and install an input handler, but I don’t know how to do that yet from the Java task inside. Run ‘mvn -X install’, you’ll get the Java commandline that is executed, execute that in another shell and you get a clou about the underlying error. Did you add the target/classes from org.xtext.example.mydsl as resource folder to the .generator project? That’s likely the cause. Check the download at the end of the post, this should work.

      ~Karsten

      Comment by kthoms — August 19, 2010 @ 9:01 PM

      • Hi Karsten.
        Thank you for your response!

        Executing the command separately in another shell results in this error:

        [main] ERROR o.e.e.m.launch.runtime.Mwe2Launcher – Cannot create a resource for ‘C:\javaee_helios\org.xtext.example.mydsl.generator/src/workflow/MyDslGenerator.mwe2′; a registered resource factory is needed
        java.lang.RuntimeException: Cannot create a resource for ‘C:\javaee_helios\org.xtext.example.mydsl.generator/src/workflow/MyDslGenerator.mwe2′; a registered resource factory is needed
        at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:394) ~[org.eclipse.emf.ecore-2.6.0.v20100614-1136.jar:na]
        at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23) ~[org.eclipse.xtext-1.0.0.v201006170321.jar:na]
        at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:47) ~[org.eclipse.emf.mwe2.launch-1.0.0.v201006150907.jar:na]
        at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74) ~[org.eclipse.emf.mwe2.launch-1.0.0.v201006150907.jar:na]
        at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35) ~[org.eclipse.emf.mwe2.launch-1.0.0.v201006150907.jar:na]

        And target/classes is defined as a resource folder in the generator project.

        And I get the same error when I download the project of this post Sorry for not mentioning this in the first place.

        –Heiko

        Comment by Heiko Tappe — August 20, 2010 @ 6:25 AM

      • No idea, sorry. I don’t get a problem.

        Comment by kthoms — August 21, 2010 @ 10:08 AM

  5. BTW, I think the snapshot repository for the fornax-plugin should be defined as a pluginRepository, shouldn’t it?

    –Heiko

    Comment by Heiko Tappe — August 20, 2010 @ 10:06 AM

    • Right. Changed that.

      Comment by kthoms — August 21, 2010 @ 10:07 AM

  6. Hi Karsten.

    This is the java command (for the generator part) that leads to the error with your sample project. Maybe you can post your command here so I can compare it to mine.

    –Heiko

    C:\Programme\Java\jdk1.6.0_21\jre\bin\java.exe -classpath “C:\temp\mvn\org.xtext.example.mydsl.generator\src;C:\temp\mvn\org.xtext.example.mydsl\target\classes;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.xtext.example.mydsl\1.0.0\org.xtext.example.mydsl-1.0.0.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.xpand\1.0.0.v201006150611\org.eclipse.xpand-1.0.0.v201006150611.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.xtend\1.0.0.v201006150611\org.eclipse.xtend-1.0.0.v201006150611.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.mwe.core\1.0.0.v201006150535\org.eclipse.emf.mwe.core-1.0.0.v201006150535.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.ecore\2.6.0.v20100614-1136\org.eclipse.emf.ecore-2.6.0.v20100614-1136.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.common\2.6.0.v20100614-1136\org.eclipse.emf.common-2.6.0.v20100614-1136.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.apache.commons.cli\1.0.0.v20080604-1500\org.apache.commons.cli-1.0.0.v20080604-1500.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.mwe2.runtime\1.0.0.v201006150446\org.eclipse.emf.mwe2.runtime-1.0.0.v201006150446.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\com.ibm.icu\4.2.1.v20100412\com.ibm.icu-4.2.1.v20100412.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.xtext\1.0.0.v201006170321\org.eclipse.xtext-1.0.0.v201006170321.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.ecore.xmi\2.5.0.v20100521-1846\org.eclipse.emf.ecore.xmi-2.5.0.v20100521-1846.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.xtext.util\1.0.0.v201006170321\org.eclipse.xtext.util-1.0.0.v201006170321.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\com.google.collect.8.0.v201006170321\com.google.collect-0.8.0.v201006170321.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\com.google.inject\2.0.0.v201003051000\com.google.inject-2.0.0.v201003051000.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.antlr.runtime\3.0.0.v200803061811\org.antlr.runtime-3.0.0.v200803061811.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.mwe.utils\1.0.0.v201006150535\org.eclipse.emf.mwe.utils-1.0.0.v201006150535.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.mwe2.launch\1.0.0.v201006150907\org.eclipse.emf.mwe2.launch-1.0.0.v201006150907.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.emf.mwe2.language\1.0.0.v201006150907\org.eclipse.emf.mwe2.language-1.0.0.v201006150907.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.xtext.common.types\1.0.0.v201006170321\org.eclipse.xtext.common.types-1.0.0.v201006170321.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.eclipse.xtend.typesystem.emf\1.0.0.v201006150611\org.eclipse.xtend.typesystem.emf-1.0.0.v201006150611.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\ch.qos.logback.classic.9.19.v20100519-1505\ch.qos.logback.classic-0.9.19.v20100519-1505.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\ch.qos.logback.core.9.19.v20100419-1216\ch.qos.logback.core-0.9.19.v20100419-1216.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.apache.commons.logging\1.1.1.v201005080502\org.apache.commons.logging-1.1.1.v201005080502.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.slf4j.api\1.5.11.v20100519-1910\org.slf4j.api-1.5.11.v20100519-1910.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\ch.qos.logback.slf4j.9.19.v20100519-1910\ch.qos.logback.slf4j-0.9.19.v20100519-1910.jar;C:\Dokumente und Einstellungen\Tappe\.m2\repository\p2\osgi\bundle\org.slf4j.log4j\1.5.11.v20100419-1106\org.slf4j.log4j-1.5.11.v20100419-1106.jar” org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher C:\temp\mvn\org.xtext.example.mydsl.generator/src/workflow/MyDslGenerator.mwe2

    Comment by Heiko Tappe — August 24, 2010 @ 6:58 AM

    • Solved! :-)

      The problem was the {basedir} prefix in the pom for the workflow. If I just say

      src/workflow/MyDslGenerator.mwe2

      everything’s fine.

      Thanks Karsten!!!

      –Heiko

      Comment by Heiko Tappe — August 24, 2010 @ 9:05 AM

      • Fine :-)

        BTW: Just uploaded a new snapshot. This will handle the antlr-gen download and fixes issues with the checkFilesets.

        Now I have to redirect the output from the forked VM to the Plugin’s log.

        Comment by Karsten — August 24, 2010 @ 9:07 AM

  7. Hi Karsten – long time no see :-)

    I just came across another problem with the fornax plugin: I need to set the stack size (eg. -Xss4096k) for the java command for executing the workflow. How can I do this?

    –Heiko

    Comment by Heiko Tappe — August 25, 2010 @ 9:13 AM

    • This is not possible yet, but I will add this feature soon. Created a feature request: http://fornax.itemis.de/jira/browse/TOM-41

      I think this could be added soon in 3.1.1-SNAPSHOT.

      Comment by Karsten — August 25, 2010 @ 11:18 AM

      • Great!
        When do you think the 3.1.1-SNAPSHOT could be available? So, what’s your definition of “soon”? ;-)

        –Heiko

        Comment by Heiko Tappe — August 25, 2010 @ 11:52 AM

      • Depends on my spare time. Maybe really soon, but don’t want to promise anything.

        Comment by kthoms — August 25, 2010 @ 1:58 PM

      • Good news. Added JVM config option, and also some more features. Instead of 3.1.1 it will be a version 3.2.0. Just deployed first snapshot 3.2.0-SNAPSHOT, this should work for you.

        Comment by kthoms — August 25, 2010 @ 11:07 PM

      • Wow! Fantastic! That was really quick. Thank you so much.
        Now I know that when you say “soon” you mean “now” :-)

        –Heiko

        Comment by Heiko Tappe — August 26, 2010 @ 6:33 AM

  8. The workflow execution doesnt work for me as the classapth is not build correctly.

    [DEBUG] “C:\Program Files\Java\jdk1.6.0_17\jre\bin\java.exe” org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher src/org/xtext/example/mydsl/GenerateMyDsl.mwe2

    But before launching mvn does debug that all dependencies which are added to the classapth.

    BTW tried it with your provied example too, same result.

    Any idea whats wrong?

    Comment by Jens — August 25, 2010 @ 12:10 PM

    • No, sorry. The command-line should be rather long. And usable by default. Would be helpful if you find something out and report this.

      Comment by kthoms — August 25, 2010 @ 2:01 PM

  9. Hi Karsten.

    The availability of xtext 1.0.1 made me wonder how I could tell the plugin to use 1.0.1 instead of 1.0.0!?

    –Heiko

    Comment by Heiko Tappe — August 26, 2010 @ 7:57 AM

    • The plugin itself would handle this transparently. Only the Require-Bundle dependencies must be updated to “1.0.1″ minimum version and a P2 repository must be defined from where Xtext 1.0.1 is available.

      Comment by kthoms — August 26, 2010 @ 6:12 PM

      • Hi Karsten,

        i just added the P2 repository from http://download.itemis.com/updates/releases to my pom file and changed my Require-Bundle dependencies to the new version 1.0.1.

        Now i get a java.lang.NoClassDefFoundError for org/antlr/Tool at grammar generation.

        The .antlr-generator-3.0.1.jar contains the Tools.class, but maybe there is a problem with embedding the antlr jar file in the new xtext version?

        Best regards Tim

        Comment by Tim Knies — September 22, 2010 @ 10:13 AM

  10. Hi Karsten,

    That works fine for me, but now the next step. When I want to build a feature containing the grammar project I get the message that at least “package” phase execution has is required.
    But when I built the feature just containing the ui, every thing works fine.
    Any ideas?

    Andreas

    Comment by Andreas Beckers — September 10, 2010 @ 7:15 AM

  11. Hi Karsten,

    Beside the problem reported on Friday, I have a different problem.
    So far we build xtext with maven 2. We have a grammar, ui and generator as maven2 artifacts, a feature with the grammar and ui.
    The feature we import into the eclipse of the developers.
    Then we have an ejb and web project for each project using the DSL. Each ejb and web are build with maven2 with an generate-sources phase invoking the generator.
    How can we have packaging ejb and use the tycho mechanism to generate the sources? Or can we use this new way only if we place the generated source in a seperate project?

    Andreas

    PS: The problem reported on Friday only occurs, when building the feature from the parent/grammar project. If it is built from within the feature project, it works.

    Comment by Andreas Beckers — September 15, 2010 @ 8:10 AM

    • The generated source can be directed to the EJB project, there is no need to have the outlets within the Tycho project. It will be also the only chance to integrate, since Tycho sets up its own lifecycle and does not allow to combine with Maven 2 dependency resolution, which is required for the EJB/WAR plugin. Best way I guess would be to have a separate codegen module.

      Comment by kthoms — September 15, 2010 @ 3:19 PM

  12. Hello, i’m having the next problem when i try to run mvn install

    [INFO] Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.mwe2.launch.ru
    ntime.Mwe2Launcher
    [INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    [INFO] at java.security.AccessController.doPrivileged(Native Method)
    [INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    [INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    [INFO] Could not find the main class: org.eclipse.emf.mwe2.launch.runtime.Mwe2Laun
    cher. Program will exit.
    [INFO] Exception in thread “main”
    [ERROR] ExitStatusException occurred while running workflow: Java returned: 1

    Maybe the org.eclipse.emf.mwe2.launch.runtime.Mwe2Launch is not being include in the classpath. I found it in the maven repository, so maven downloaded it correctly. When i launch the command with the -X option i didn’t see the full command.

    *Sorry for my english, i’m spanish

    Comment by Axel — September 17, 2010 @ 11:13 AM

    • Without getting the full Java command it is hard to say what’s wrong. And normally you should get it. You could use mvnDebug to debug the plugin.

      Comment by kthoms — September 27, 2010 @ 5:40 PM

  13. Hi Karsten,

    i just added the P2 repository from http://download.itemis.com/updates/releases to my pom file and changed my Require-Bundle dependencies to the new version 1.0.1.

    Now i get a java.lang.NoClassDefFoundError for org.antlr.Tool at grammar generation.

    The .antlr-generator-3.0.1.jar contains the Tools.class, but maybe there is a problem with embedding the antlr-jar file in the new xtext 1.0.1 version?

    Comment by Tim Knies — September 23, 2010 @ 7:24 AM

    • I did not had the time to test with 1.0.1 properly, but experienced the same. I don’t think it is a major problem, but so far no solution.

      Comment by kthoms — September 27, 2010 @ 5:41 PM

  14. Hi Karsten,

    I’m trying to build the sample project (posted on this page) but I get following error:

    [INFO] Reactor Summary:
    [INFO]
    [INFO] org.xtext.example.mydsl.MyDsl – Parent ………… SUCCESS [0.141s]
    [INFO] org.xtext.example.mydsl.MyDsl – Grammar ……….. FAILURE [0.516s]
    [INFO] org.xtext.example.mydsl.MyDsl – UI ……………. SKIPPED
    [INFO] org.xtext.example.mydsl.MyDsl – Generator ……… SKIPPED
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 29.205s
    [INFO] Finished at: Tue Sep 28 06:24:02 VET 2010
    [INFO] Final Memory: 64M/123M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.2.0-SNAPSHOT:run-workflow (default) on project org.xtext.example.mydsl: Execution default of goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.2.0-SNAPSHOT:run-workflow failed: Plugin org.fornax.toolsupport:fornax-oaw-m2-plugin:3.2.0-SNAPSHOT or one of its dependencies could not be resolved: Unable to get dependency information for org.fornax.toolsupport:fornax-oaw-m2-plugin:maven-plugin:3.2.0-SNAPSHOT: Failed to process POM for org.fornax.toolsupport:fornax-oaw-m2-plugin:maven-plugin:3.2.0-SNAPSHOT: Non-resolvable parent POM org.fornax:fornax-parent:3.2 for org.fornax.toolsupport:fornax-oaw-m2-plugin:3.2.0-SNAPSHOT: Failed to resolve POM for org.fornax:fornax-parent:3.2 due to Missing:
    ———-
    1) org.fornax:fornax-parent:pom:3.2
    ———-
    1 required artifact is missing.

    for artifact:
    org.fornax:fornax-parent:pom:3.2

    from the specified remote repositories:
    fornax-snapshots (http://www.fornax-platform.org/archiva/repository/snapshots/, releases=false, snapshots=true),
    central (http://repo1.maven.org/maven2, releases=true, snapshots=false)
    -> [Help 1]

    How can I handle this ?

    Thanks in advance

    Comment by Flo — September 28, 2010 @ 10:56 AM

  15. I’ve downloaded the demo project and did a “mvn clean install -X”

    but I got:

    [ERROR] Failed to execute goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow (default) on project org.xtext.example.mydsl: Execution default of goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow failed: Plugin org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT or one of its dependencies could not be resolved: Failed to collect dependencies for org.fornax.toolsupport:fornax-oaw-m2-plugin:jar:3.1.0-20100824.081209-4 (): Failed to read artifact descriptor for org.fornax.toolsupport:fornax-oaw-m2-plugin:jar:3.1.0-20100824.081209-4: Failed to resolve POM for org.fornax:fornax-parent:3.2 due to The following artifacts could not be resolved: org.fornax:fornax-parent:pom:3.2: Failure to find org.fornax:fornax-parent:pom:3.2 in http://repo1.maven.org/maven2 was cached in the local repository. Resolution will not be reattempted until the update interval of central has elapsed or updates are forced. -> [Help 1]

    Any suggestions would be greatly appreciated.

    Comment by Mark Christiaens — October 1, 2010 @ 10:08 AM

  16. Hi Karsten,

    I tried to rebuild a xtext project exactly against your settings. But I have no success to run the generation process with maven (I spent already 2 days on this topic)

    It seems that classpath isn’t correct:

    Output from maven:
    *********

    [INFO] Fornax oAW/MWE/MWE2 Maven2 Plugin V3.1.1
    [DEBUG] Added resource to classpath: file:/D:/_projects/current/xtext/org.xtext.example.mydsl/src//
    [DEBUG] Added dependency to classpath: file:/C:/Users/k1708/.m2/repository/p2/osgi/bundle/org.eclipse.xtext/1.0.1.v201008251220/org.eclipse.xtext-1.0.1.v201008251220.jar
    [DEBUG] Added dependency to classpath: file:/C:/Users/k1708/.m2/repository/p2/osgi/bundle/org.eclipse.emf.ecore.xmi/2.5.0.v20100521-1846/org.eclipse.emf.ecore.xmi-2.5.0.v20100521-1846.jar
    [DEBUG] Added dependency to classpath: file:/C:/Users/k1708/.m2/repository/p2/osgi/bundle/org.eclipse.emf.ecore/2.6.1.v20100914-1218/org.eclipse.emf.ecore-2.6.1.v20100914-1218.jar
    ….
    java.exe -classpath D:\_projects\current\xtext\org.xtext.example.mydsl\src org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher src/org/xtext/example/mydsl/GenerateMyDsl.mwe2
    [INFO] java.lang.NoClassDefFoundError: org/eclipse/emf/mwe2/launch/runtime/Mwe2Launcher
    [INFO] Caused by: java.lang.ClassNotFoundException: org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher
    [INFO] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    [INFO] at java.security.AccessController.doPrivileged(Native Method)
    [INFO] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    [INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    [INFO] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    [INFO] Could not find the main class: org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher. Program will exit.
    [INFO] Exception in thread “main”
    [ERROR] ExitStatusException occurred while running workflow: Java returned: 1
    ….

    *********

    In the log I see several “Added dependency to classpath: …) statements.

    But on running the Mwe2Launcher the classpath is NOT correctly set.

    I tried it with fornax-oaw-m2-plugin in version 3.1.0-SNAPSHOT and 3.2.0-SNAPSHOT

    Can you give me a hint what’s going on / what is wrong?

    TIA

    Martin

    Comment by Martin — October 4, 2010 @ 11:53 AM

    • You are building against Xtext 1.0.1, the example is for Xtext 1.0.0. I haven’t proved the sample for Xtext 1.0.1 yet. I tried directly after release but had some problems and had no time for the topic yet. I will deal with it next week.

      The classpath printed is definetely too short, it should contain all Jars that are mentioned before with “Added dependency to classpath”.

      Comment by Karsten — October 4, 2010 @ 4:51 PM

      • I tried it also with your downloadable example and I did only the mvn install on the command line.

        This leads also to this error…

        Comment by Martin — October 4, 2010 @ 4:57 PM

      • Just did the same to double-proof, but works on my machine. I will add an example for Xtext 1.0.1 and work on the Fornax Plugin 3.2.0 soon.

        Comment by Karsten — October 5, 2010 @ 9:52 AM

      • Hi Karsten,

        I have the same problem. I’m using Eclipse Helios with Xtext 1.0.0 on Windows 7. Also, my projects are on a different drive (D) than the local Maven repository which contains all the jars required for Xtext (C).

        I was partly successful in debugging the plugin with mvnDebug and I could see that something is going wrong with the classpath string in JavaTaskBuilder.configureClasspath(). While the local classpath variable contains all paths in the form:

        /D:/workspace/org.xtext.example.mydsl/src/src//;/C:/Users/me/.m2/repository/p2/osgi/bundle/org.eclipse.xtext/1.0.1.v201008251220/org.eclipse.xtext-1.0.1.v201008251220.jar; ...

        after the call to javaTask.setClasspath(new Path(antProject, classpath)); I find the following in javaTask.cmdl:


        C:\Program Files\Java\jre6\bin\java.exe" -classpath D:\C11865\repo\trunk\src\dsl\plugins\com.bbraun.p123.sdl\src

        and this in javaTask.cmdl.classpath:


        D:\D;D:\workspace\org.xtext.example.mydsl\src;D:\C;D:\Users\me\.m2\repository\p2\osgi\bundle\org.eclipse.xtext\1.0.1.v201008251220\org.eclipse.xtext-1.0.1.v201008251220.jar; ...

        It seems that the path is badly transformed into Windows paths and therefore truncated.

        BTW, on my Linux machine at home everything works fine.

        Do you have any idea how this could be fixed?

        Thanks, Tobias

        Comment by Tobias — December 2, 2010 @ 7:10 AM

      • Thanks to Tobias findings and some time for debugging i found the problem. If you call url.getFile() on Windows you receive a path with a leading / . This path is not a valid. If i change the configureClasspath method to

        private void configureClasspath() {
        String classpath = “”;
        for (URL url : realm.getConstituents()) {
        String file = url.getFile();

        if (System.getProperty(“os.name”).startsWith(“Windows”)) {
        file = file.substring(1);
        }

        if (“”.equals(classpath)) {
        classpath += file;
        } else {
        classpath += System.getProperty(“path.separator”) + file;
        }
        }
        javaTask.setClasspath(new Path(antProject, classpath));
        }
        it does work for me on Windows XP.

        Comment by Jens — February 1, 2011 @ 1:36 PM

    • this also happend to me when the local repository was on a different drive than the project that I wanted to build

      Comment by Martin Trummer — March 1, 2011 @ 6:01 PM

  17. I tried this out using maven 3.0 and xtext 1.0.1 and got a similar error to one of the aforementioned posters.

    [ERROR] Failed to execute goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow (default) on project org.xtext.example.hlm: Execution default of goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow failed: Plugin org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT or one of its dependencies could not be resolved: Failed to collect dependencies for org.fornax.toolsupport:fornax-oaw-m2-plugin:jar:3.1.0-20100824.081209-4 (): Failed to read artifact descriptor for org.fornax.toolsupport:fornax-oaw-m2-plugin:jar:3.1.0-20100824.081209-4: Failure to find org.fornax:fornax-parent:pom:3.2 in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow (default) on project org.xtext.example.hlm: Execution default of goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow failed: Plugin org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT or one of its dependencies could not be resolved: Failed to collect dependencies for org.fornax.toolsupport:fornax-oaw-m2-plugin:jar:3.1.0-20100824.081209-4 ()
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:211)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT:run-workflow failed: Plugin org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT or one of its dependencies could not be resolved: Failed to collect dependencies for org.fornax.toolsupport:fornax-oaw-m2-plugin:jar:3.1.0-20100824.081209-4 ()
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:86)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195)
    … 19 more
    Caused by: org.apache.maven.plugin.PluginResolutionException: Plugin org.fornax.toolsupport:fornax-oaw-m2-plugin:3.1.0-SNAPSHOT or one of its depen
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:159)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.createPluginRealm(DefaultMavenPluginManager.java:316)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.setupPluginRealm(DefaultMavenPluginManager.java:284)
    at org.apache.maven.plugin.DefaultBuildPluginManager.getPluginRealm(DefaultBuildPluginManager.java:186)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:82)
    … 20 more
    Caused by: org.sonatype.aether.collection.DependencyCollectionException: Failed to collect dependencies for org.fornax.toolsupport:fornax-oaw-m2-pl
    at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:197)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:272)
    at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve(DefaultPluginDependenciesResolver.java:148)
    … 24 more
    Caused by: org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.fornax.toolsupport:fornax-oaw-m2-
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:308)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:170)
    at org.sonatype.aether.impl.internal.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:191)
    … 26 more
    Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Failure to find org.fornax:fornax-parent:pom:3.2 in http://repo1.maven.org
    at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:119)
    at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:819)
    at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:670)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:308)
    at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:299)
    … 28 more
    Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Failure to find org.fornax:fornax-parent:pom:3.2 in http://repo1.maven.org/m
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:488)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:190)
    at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:115)
    … 33 more
    Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Failure to find org.fornax:fornax-parent:pom:3.2 in http://repo1.maven.org/maven
    at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:191)
    at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:384)
    … 35 more
    [ERROR]
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
    [ERROR]
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR] mvn -rf :org.xtext.example.hlm

    Any updates on the example for Xtext 1.0.1. Thanks

    Comment by pg — October 23, 2010 @ 10:51 PM

    • Try to add this to the pom.xml

      fornax-nexus-repo
      http://fornax.itemis.de/nexus/content/groups/public/

      Comment by Antons Kranga — February 11, 2011 @ 7:14 AM

  18. On a fresh installed “Eclipse 3.6 Helios Modelling Tools” I can’t import the packges

    * ch.qos.logback.classic
    * ch.qos.logback.core.joran.spi
    * org.slf4j

    What’s going wrong here?

    Comment by Tobias — November 2, 2010 @ 2:27 PM

  19. Hi Karsten!

    What do you think could be the reason for running workflows outside Eclipse (Helios) from command line is considerably (for me: 4 times) slower than from within Eclipse (using xtext 1.0.1)? Could this be an antlr problem? Is there anything I can do about this?

    –Heiko

    Comment by Heiko Tappe — November 24, 2010 @ 8:15 AM

    • I don’t know. You should ask that question in the Eclipse Xtext forum.

      Comment by Karsten Thoms — November 24, 2010 @ 10:45 AM

      • Karsten,

        I followed your advice and posted to the Eclipse Xtext forum.

        After removing the logback stuff from the manifest file and using just standard log4j the performance was just like within Eclipse. And I didn’t notice any negative side effects!?

        What do you think?

        –Heiko

        Comment by Heiko Tappe — November 29, 2010 @ 4:22 PM

  20. Logback states that it is a successor of log4j and that it provides better performance. Strange that it is the opposite.

    ~Karsten

    Comment by kthoms — December 3, 2010 @ 7:09 PM

  21. Hi Karsten,

    i noticed a problem with this example under my windows installation.
    When you put the example project into an folder with whitespaces in it, the build will fail.
    It’s only possible to build this project (under windows?) in an folder without any special characters.

    - Tim

    Comment by Tim Knies — December 8, 2010 @ 7:41 AM

    • I’m on Mac and usually avoid having directories with whitespaces. I would expect that it should work in such an environment.

      ~Karsten

      Comment by kthoms — December 8, 2010 @ 8:37 AM

  22. Hi,

    I am using Eclipse 3.6 and I couldn’t add the package org.sl4j and others.

    So I added them from Orbit, but now when compiling with maven, it tells me that he cannot resolves the dependency for org.sl4j, since it is not in the helios repository and he only knows about that…

    Any solution? Why this dependency by the way?

    Comment by Victor — January 27, 2011 @ 2:59 PM

    • The artifact is named org.slf4j, not org.sl4j

      Comment by kthoms — February 1, 2011 @ 6:12 PM

      • Yes, sorry for the typo, I meant slf4j, the resolving of the dependency works inside Eclipse, but only because I added the orbit repository.

        Actually, it seems this situation changed because I don’t get the error anymore, maybe a temporary problem with the helios repository…

        Thank you for your help!

        Comment by Victor — February 1, 2011 @ 6:35 PM

  23. Hi,

    This is a very useful plugin. I have spent a couple of days playing with it. In the end I did not use tycho as I needed to have the model available as a jar dep in a project (along with all the xtext deps) and I was not sure tycho could achieve that. I used the mvn -X output to work out what jars were required and then I manually constructed my own set of deps from a repo I had created using the maven-eclipse-plugin to-maven target. Works great, until I wanted to integrate this into a larger build. I spent some time and discovered the plugin does not correctly set the Current Working directory when calling the Runtime.exec() in ant Execution task (called from Java task)

    I submitted a patch to the news group as I was not sure where else to submit it. Happy to provide the patch if required. My build now works as part of a much larger build.

    The added benefit is I do not need to have the org.xtext.example.mydsl.parent (in your example) in a directory. I can have it as a pom.xml and because of this fix the wme2 file still finds all the right things using the relative dir / uri references.

    Thanks again

    Cheers
    Jason

    Comment by Jason Pell — February 4, 2011 @ 2:26 PM

  24. Hello!
    Thanks for this great tutorial. I would like to go further by adding my testing projet (mydsl.ui.test having to Require-Bundle “mydsl” and “mydsl.ui”) but tycho can’t find my “StandaloneSetup” class within “mydsl” project.)
    Everything works great from eclipse, but fails with tycho, any idea?

    Regards,
    Xavier

    Comment by Xavier Seignard — February 7, 2011 @ 4:24 PM

    • Actually StandAloneSetup is not compiled during the MWE workflow. I had to use StandAloneSetupGenerated.
      But now I’ve got problems with some of my test which are trying to get the number of IMarkers, but it is incompatible with a headless build… I’ve to find another way to do it.
      Regards,
      Xavier

      Comment by Xavier Seignard — February 8, 2011 @ 8:22 AM

  25. thanks for this helpful article

    here’s a list of changes I had to make in my project, to make the maven build work:

    in the MANIFEST.MF (of the dsl project) I had to specify this Bundle-Version:

    1.0.0.qualifier

    I use this URL for the fornax repository (because I use fornax-oaw-m2-plugin: 3.2.0)
    http://fornax.itemis.de/nexus/content/groups/public/

    I only needed

    org.apache.log4j

    as “Import-Package” in the MANIFEST.MF

    I had to remove

    ;resolution:=optional

    for

    org.eclipse.emf.mwe2.launch

    in the MANIFEST.MF

    Comment by Martin Trummer — March 1, 2011 @ 4:10 PM

  26. How could I run the generator from another maven-project?

    i.e. I have made ‘mvn deploy’ in my dsl project, so all 3 artifacts are available in my shared repository

    now, in my external project, I want to add a dependency to the generator project and then configure the fornax-oaw-m2-plugin to run a workflow in the external project (that will in turn use a workflow in the generator).
    but this will not work, because the Mwe2Launcher will be missing on the classpath.
    How is this supposed to work?
    Do I somehow need to run the tycho plugin in the external project? Or should the generator project’s jar file include the mwe2.launch jar file?

    Comment by Martin Trummer — March 1, 2011 @ 7:05 PM

  27. Hello,

    I am trying to get this tutorial running and I am pretty close to success.
    But unfortunately the fornax-oaw-m2-plugin ends in an infinite loop after trying to download antlr.

    This seems to be, because I am behind a proxy and the AntlrToolFacade throws a java.net.ConnectException.

    Does anybody have a hint, how to solve this problem?

    Thanks and regards,
    Stefan

    Comment by Stefan R — May 17, 2011 @ 12:06 PM

    • Hi Stefan,

      You could download the antlr jar yourself (URL should be visible) and place it in the root of the runtime project.

      ~Karsten

      Comment by kthoms — May 30, 2011 @ 5:32 AM

      • Hi,

        thanks for the hint. But I’m not sure, what you mean by “runtime project”. I created the grammar-, generator- and ui-project using the wizard. Then I copied the antlr-generator-3.0.1.jar into the grammar- and generator-project. Still my build would end up in an infinite loop after throwing a ConnectException.
        Isn’t it somehow possible to define a dependency on the antlr maven artifact?

        Thanks!
        Stefan

        Comment by Stefan R — May 31, 2011 @ 7:12 AM

      • “runtime project” = “grammar project”. Runtime because it can be used without UI just as a runtime library. No idea why you are facing that loop. Run with “mvn -X” and you should get the java command line that is executed. Try to execute this on your own. Note that this project was tested against Xtext 0.7.2.

        With newer Tycho versions you could also add “normal” Maven dependencies also. Therefore the target-platform-configuration plugin must be configured with
        consider
        see https://docs.sonatype.org/display/TYCHO/Dependency+on+pom-first+artifacts

        Comment by kthoms — May 31, 2011 @ 8:24 AM

  28. Hello, thanks for your blog. It was very helpful.
    Worked so far for the 0.10.0 version of tycho but with all newer versions I always get a NullPointerException (0.11.0 – 0.13.0-SNAPSHOT)
    I’m using fornax-oaw-m2-plugin 3.2.3.
    Do I miss some additional needed steps when using newer versions of tycho?

    Thanks and regards!

    Nylan

    [ERROR] Internal error: java.lang.NullPointerException -> [Help 1]
    org.apache.maven.InternalErrorException: Internal error: java.lang.NullPointerException
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    Caused by: java.lang.NullPointerException
    at org.eclipse.tycho.core.osgitools.EquinoxResolver.assertResolved(EquinoxResolver.java:222)
    at org.eclipse.tycho.core.osgitools.EquinoxResolver.newResolvedState(EquinoxResolver.java:65)
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.getResolverState(OsgiBundleProject.java:204)
    at org.eclipse.tycho.core.osgitools.OsgiBundleProject.resolveClassPath(OsgiBundleProject.java:150)
    at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.resolveProject(DefaultTychoDependencyResolver.java:96)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:91)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:273)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    … 11 more
    [ERROR]
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/InternalErrorException

    Comment by Nylan — June 21, 2011 @ 2:19 PM

  29. [...] workflow into the Tycho build, I was basically able to use the info in the very good and detailed tutorial by Karsten Thoms. To make it work for our specific project setup and for the latest Xtext version I still had to [...]

    Pingback by Run MWE2 workflows for Xtext 2.0 in a Tycho build « Geschreibsel — July 15, 2011 @ 8:05 PM

  30. Hi Karsten,

    is there a chance to create a Maven module as described above and include the referenced Eclipse JAR files?
    Tycho and your blog are nice facilities, but the created jar has a size of a few KiB. Compared with the size of XText and its dependecnies, the resulting JAR is too small.

    Without the referenced plugins of manifest.mf file, I got compile errors, if I want to use my generated model in other Maven modules.

    Ciao, Micha

    Comment by Michael Burkhardt — August 18, 2011 @ 5:11 PM

    • Hi Micha,

      I’m not quite sure of what you want. Of course the resulting Jar is quite small and it would not contain its required dependencies within. After all, it is the plugin that is created that you should be able to deploy in Eclipse. And you could of course also use it standalone, but this requires adding its dependencies on the classpath. Are you talking about creating an “Uberjar” that contains the generator and all its dependencies in a fat jar? This is also possible, but off-topic here.

      Regards,
      ~Karsten

      Comment by kthoms — August 18, 2011 @ 5:49 PM

  31. Hi Karsten,

    many thanks for this example! I have boldly tried to adapt it for Xtext2.1 but my reward was the same NPE as reported by Nylan.

    What I’ve changed:

    org.sonatype.tycho -> org.eclipse.tycho

    version.tycho: 0.9.0 -> 0.13.0

    helios -> indigo

    When debugging it seems the EquinoxResolver bailed out fundamentally: the UserState that should provide all known bundles only had the system-bundle, nothing else.

    Do you have experience with using a recent version of tycho for XText 2.1?

    thanks,
    Stephan

    Comment by Stephan Herrmann — November 25, 2011 @ 8:12 PM

    • Stephan,

      one possible cause for the NPE can be that you need to specify a log4j configuration.

      org.fornax.toolsupport
      fornax-oaw-m2-plugin

      -Dlog4j.configuration=file:${basedir}/log4j.properties

      Comment by Karsten Thoms — November 28, 2011 @ 6:02 PM

      • hooray, yes with a proper logj4 configuration the example now builds even with tycho 0.13.

        From your post I first wasn’t sure, where exactly to put the log4j.configuration, the -D option looked like command line, but then adding a log4j.configuration element inside the configuration element of the oaw plugin did the trick.

        Many thanks!
        Stephan

        Comment by Stephan Herrmann — November 30, 2011 @ 11:53 AM

    • some more comments, sorry for the noise:

      My “hooray” was premature, it seems I tested another version than intended, the NPE came back on me …

      Next I filed Bug 366967 – NPE in EquinoxResolver in Xtext example project [1]

      From further trial-and-error and from comments in the bug I learned that the line
      <module>./pom-grammar.xml</module>
      isn’t actually legal with maven, a module must be specified using a directory.

      By extracting a designated parent-pom project I could finally get it to run using tycho 0.14.0-SNAPSHOT.

      (0.13.0 raised a ClassNotFoundException, can’t find the Mwe2Launcher, but since this works im 0.14.0-SNAPSHOT I’m not pursuing this further).

      maybe these findings will help others,
      Stephan

      [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=366967

      Comment by Stephan Herrmann — December 20, 2011 @ 7:27 PM

      • for cross-reference: in the mentioned bug 366967 the tycho folks decided to let tycho fail early if multiple modules of the same reactor sit in the same directory.
        In my understanding this rules out the reference to a sub-module as “./pom-grammar.xml” — separating parent pom and the grammar project seems to be mandatory.

        Comment by Stephan Herrmann — May 24, 2012 @ 9:04 PM

  32. Take a look at project Spray. The project runs fine with Xtext 2.1.1 and Tycho 0.13.0. Note that xtend-gen folders must be checked in currently.

    Comment by Karsten Thoms — November 26, 2011 @ 4:43 PM

  33. Currently, this compiles for me:

    org.eclipse.xtend2
    org.eclipse.xtend2.lib
    2.2.1

    org.eclipse.xtext
    org.eclipse.xtext.xtend2.lib
    2.2.0.v201112121625

    com.google.inject
    guice
    3.0

    with

    maven.eclipse.org
    http://maven.eclipse.org/nexus/content/groups/public/

    xtend
    http://build.eclipse.org/common/xtend/maven/

    xtext
    http://build.eclipse.org/common/xtext/maven/maven-snapshot/final/

    Comment by dschulten — January 9, 2012 @ 12:07 AM

  34. Check out this excellent work / example for xtext 2.2 and 2.3: http://github.com/aphethean/xtext-maven-examples

    Comment by Martijn Morrien (@Yacse) — October 11, 2012 @ 9:46 PM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Silver is the New Black Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 375 other followers

%d bloggers like this: