Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » rootPath, alternative folder layouts and maven build
rootPath, alternative folder layouts and maven build [message #1740069] Mon, 08 August 2016 21:59 Go to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Hello.

I have a language created with Xtext 2.10 where the Xtext-generated plugin folders are all contained in a folder which is not directly under the workspace. More precisely, I have a git repository where the language, called "xtumlrt.common", is under "plugins/xtumlrt/xtext/common" from the root of the repository. This folder contains all the plugins generated by Xtext.

The workflow works fine when I run it from my Eclipse workspace. The problem is that when I build with maven, the execution of the workflow fails with "The project's path '../org.eclipse.papyrusrt.xtumlrt.xtext.common' does not exist" (the full exception is at the end), in spite of the fact that
"plugins/xtumlrt/xtext/common/org.eclipse.papyrusrt.xtumlrt.xtext.common" does exist.

It looks like the problem is when the workflow calls StandardProjectConfig.addProjectMapping, and it seems to be using the rootPath, which is "..", the default given by Xtext.

My question is, is the problem indeed the rootPath or something else? Is the ".." setting for rootPath assuming that the workflow is executed from the folder of the plugin containing the workflow? And what exactly is the rootPath supposed to be? The path to the folder containing all the generated plugins, or the path to the root of the workspace, or something else?

Any suggestions on how to make it work on both the workspace and a maven build?

Thanks


The full exception is this:

155  [org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main()] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow org.eclipse.papyrusrt.xtumlrt.xtext.common.GenerateXTUMLRT: The project's path '../org.eclipse.papyrusrt.xtumlrt.xtext.common' does not exist
java.lang.RuntimeException: Problems running workflow org.eclipse.papyrusrt.xtumlrt.xtext.common.GenerateXTUMLRT: The project's path '../org.eclipse.papyrusrt.xtumlrt.xtext.common' does not exist
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:104)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:62)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:78)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:36)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.eclipse.emf.mwe.core.ConfigurationException: The project's path '../org.eclipse.papyrusrt.xtumlrt.xtext.common' does not exist
	at org.eclipse.emf.mwe.utils.StandaloneSetup.addProjectMapping(StandaloneSetup.java:265)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorStandaloneSetup$1.apply(XtextGeneratorStandaloneSetup.java:66)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorStandaloneSetup$1.apply(XtextGeneratorStandaloneSetup.java:1)
	at org.eclipse.xtext.xbase.lib.IteratorExtensions.forEach(IteratorExtensions.java:363)
	at org.eclipse.xtext.xbase.lib.IterableExtensions.forEach(IterableExtensions.java:333)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorStandaloneSetup.setup(XtextGeneratorStandaloneSetup.java:69)
	at org.eclipse.xtext.xtext.generator.XtextGeneratorStandaloneSetup.initialize(XtextGeneratorStandaloneSetup.java:45)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.initialize(XtextGenerator.java:172)
	at org.eclipse.xtext.xtext.generator.XtextGenerator.checkConfigurationInternal(XtextGenerator.java:120)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2.checkConfiguration(AbstractWorkflowComponent2.java:21)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.preInvoke(Mwe2Bridge.java:65)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.preInvoke(AbstractWorkflowComponent.java:197)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.preInvoke(AbstractCompositeWorkflowComponent.java:29)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:18)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)



[SOLVED] Re: rootPath, alternative folder layouts and maven build [message #1740152 is a reply to message #1740069] Tue, 09 August 2016 19:45 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
So the rootPath is indeed the path to the folder that contains all the generated xtext projects.

To summarize the problem I had, running the GenerateMyLanguage.mwe2 workflow worked when running it within the Eclipse workspace, but failed when running it from a hudson-triggered maven build, complaining that it couldn't find the path "../my.language.runtime.plugin".

The problem is that the value of rootPath is relative, and therefore dependent on the working directory used when running the workflow, and this working directory is not necessarily the same when running in Eclipse using the default launch configuration, and when running a Maven build.

The trick to make it work both within the Eclipse workspace and a separate Maven build is to do two things:

In the workflow, define a "workspace" property with a default value that points to the local path, and redefine "rootPath" to use this property:

module org.eclipse.papyrusrt.xtumlrt.xtext.common.GenerateXtextXtumlrt

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

var workspace = "../../../../.."
var rootPath = "${workspace}/plugins/xtumlrt/xtext/common"

Workflow {
//...


In my case, I set workspace to "../../../../.." because the working directory is the location of my xtext generated runtime plugin project "org.eclipse.papyrusrt.xtumlrt.xtext.common" which is located at "plugins/xtumlrt/xtext/common" in my git repository.

This works in an Eclipse workspace because when you run the workflow, a default launch configuration is created which uses the path of the xtext generated runtime plugin (in my case 'org.eclipse.papyrusrt.xtumlrt.xtext.common') as the working directory.

The second thing is to ensure that the POM file which calls the Mwe2Launcher passes an extra "-p workspace=<build-path>" to the launcher. For example, in my case, I run the maven build from a Hudson instance, which executes from some working directory (defined by Hudson), and the workspace is created by a Hudson instance as "./source" (where "." is the Hudson working directory). So one needs to configure the "exec-maven-plugin" that calls the launcher as follows:

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>exec-maven-plugin</artifactId>
				<version>${exec-maven.version}</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>java</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<includeProjectDependencies>false</includeProjectDependencies>
					<includePluginDependencies>true</includePluginDependencies>
					<mainClass>org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher</mainClass>
					<arguments>
						<argument>file://${project.basedir}/src/org/eclipse/papyrusrt/xtumlrt/xtext/common/GenerateXtextXtumlrt.mwe2</argument>
						<argument>-p</argument>
						<argument>workspace=./source</argument>
					</arguments>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>org.eclipse.xtext</groupId>
						<artifactId>org.eclipse.xtext.xtext</artifactId>
						<version>${xtext.version}</version>
					</dependency>
					<dependency>
						<groupId>org.eclipse.xtext</groupId>
						<artifactId>org.eclipse.xtext.xbase</artifactId>
						<version>${xtext.version}</version>
					</dependency>
					<dependency>
						<groupId>org.eclipse.papyrusrt</groupId>
						<artifactId>org.eclipse.papyrusrt.xtumlrt.common.model</artifactId>
						<version>0.7.2-SNAPSHOT</version>
					</dependency>
				</dependencies>
			</plugin>



In this case, the lines

						<argument>-p</argument>
						<argument>workspace=./source</argument>


pass the value of "workspace" to the launcher, which then results in assigning "./source/plugins/xtumlrt/xtext/common" to rootPath, and the rest can be correctly resolved.
Previous Topic:How to set system environment variable eclipse configuration file?
Next Topic:How to specify a super class in JvmInferrer
Goto Forum:
  


Current Time: Sun Apr 14 22:46:22 GMT 2024

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

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

Back to the top