Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [SOLVED] Resolve cross references from a different DSL during Maven build
[SOLVED] Resolve cross references from a different DSL during Maven build [message #1725763] Mon, 07 March 2016 13:39 Go to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Hi all,

I have two DSLs, where one DSL has cross references to the other.

For example I can define something like this in DSL A:

package myservice

service MyService {
     list : GET 
     get : GET
     save : POST
}


Then I can use the defined service and its methods in DSL B:

package myclient
import myservice

client MyService {
     list
     get
}


Based on this I can generate client code for the "list" and "get" methods of MyService in Eclipse.

Now let's assume the DSL A snippet is in a file called MyService.dsla and the DSL B snippet is in MyClient.dslb

I would like to achieve the following:
1. Put the file MyService.dsla in it's own Maven artifact (and generate there some stuff that is not related to DSL B at all).
2. Create a separate artifact which contains MyClient.dslb, include the previously built MyService.dsla artifact as a Maven dependency, and generate the DSL B related code based on it.

I can perform the first step. I created an artifact, and I can build it and include MyService.dsla.
I attached the POM to this comment as "myservice-pom.xml" It is mainly from the xtext-examples, I marked the only point where I added new configuration, which tells Maven to include src/main/dsla into the built artifact. This directory contains the MyService.dsla file by my conventions.

I attached the POM of the second artifact as "myclient-pom.xml". It is a standard POM from the xtext-examples. I tried to add the first artifact as a standard dependency of the artifact itself and for the xtext-maven-plugin as well, but I got the same error during a Maven build in both cases:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myclient 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myclient ---
[INFO] Deleting /path/to/myclient/target
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default) @ myclient ---
[INFO] 
[INFO] --- build-helper-maven-plugin:1.8:add-source (default) @ myclient ---
[INFO] Source directory: /path/to/myclient/target/generated-sources/xtend added.
[INFO] Source directory: /path/to/myclient/target/generated-sources/xtend added.
[INFO] 
[INFO] --- xtext-maven-plugin:2.9.1:generate (default) @ myclient ---
[INFO] Encoding: UTF-8
[INFO] Compiler source level: 1.8
[INFO] Compiler target level: 1.8
[INFO] Using common types.
[INFO] Collecting source models.
[INFO] Installing type provider.
[INFO] Generating stubs into /path/to/myclient/target/xtext-temp/stubs
[INFO] /path/to/myclient/target/xtext-temp/stubs
[INFO] Nothing to compile. Stubs compilation was skipped.
[INFO] Installing type provider for stubs.
[INFO] Validate and generate.
[INFO] Starting validation for input: 'MyClient.dslb'
[ERROR] ERROR:Couldn't resolve reference to Service 'MyService'. (file:/path/to/myclient/src/main/resources/MyClient.dslb line : 3 column : 9)
[ERROR] ERROR:Couldn't resolve reference to ServiceMethod 'get'. (file:/path/to/myclient/src/main/resources/MyClient.dslb line : 4 column : 3)
[ERROR] ERROR:Couldn't resolve reference to ServiceMethod 'list'. (file:/path/to/myclient/src/main/resources/MyClient.dslb line : 5 column : 3)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.247 s
[INFO] Finished at: 2016-03-07T14:25:11+01:00
[INFO] Final Memory: 23M/310M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.xtext:xtext-maven-plugin:2.9.1:generate (default) on project myclient: Execution failed due to a severe validation error. -> [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] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


So, how should I configure my Maven artifacts to be able to build my second artifact successfully with this setup?

Thank you.

[Updated on: Tue, 08 March 2016 16:10]

Report message to a moderator

Re: Resolve cross references from a different DSL during Maven build [message #1725765 is a reply to message #1725763] Mon, 07 March 2016 13:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi you have to add all standalonesetups to the maven plugin.

and a dependency to the jar containing the models if you have


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 07 March 2016 13:50]

Report message to a moderator

Re: Resolve cross references from a different DSL during Maven build [message #1725775 is a reply to message #1725765] Mon, 07 March 2016 14:58 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Hi Christian, thanks for the quick reply.

I tried to apply what you told in your comment but I still could not make it work.

Here you can see my xtext-maven-plugin config in the POM:

<plugin>
	<groupId>org.eclipse.xtext</groupId>
	<artifactId>xtext-maven-plugin</artifactId>
	<version>${xtext-version}</version>
	<executions>
		<execution>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<sourceRoots>
			<sourceRoot>src/main/resources</sourceRoot>
		</sourceRoots>
		<languages>
			<language>
				<setup>dsla.DslAStandaloneSetup</setup>
				<setup>dslb.DslBStandaloneSetup</setup>
				<outputConfigurations>
					<outputConfiguration>
						<outputDirectory>target/generated-sources/xtend/</outputDirectory>
					</outputConfiguration>
				</outputConfigurations>
			</language>
		</languages>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>dsla</groupId>
			<artifactId>dsla</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>dslb</groupId>
			<artifactId>dslb</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>myservice</groupId>
			<artifactId>myservice</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
	</dependencies>
</plugin>


With the above configuration I get the same error.
If I switch the order of the StandaloneConfigurations, the plugin doesn't process the MyClient.dslb file.
I also tried to put the DslAStandaloneConfiguration into its own <language> tag but then I got the original error again.

I also tried to move the MyService.dsla file into the same artifact as the MyClient.dslb and built them together.
In that case the above configuration results in the same error.
With switched StandaloneConfigurations, only the MyService.dsla is processed.
With a separate <language> tag I got the error original error.

[Updated on: Mon, 07 March 2016 15:03]

Report message to a moderator

Re: Resolve cross references from a different DSL during Maven build [message #1725776 is a reply to message #1725775] Mon, 07 March 2016 15:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Can you share complete code

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolve cross references from a different DSL during Maven build [message #1725786 is a reply to message #1725776] Mon, 07 March 2016 16:01 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
OK, tomorrow morning I'll prepare a simplified version of the whole thing with the same configuration and post it here.
Re: Resolve cross references from a different DSL during Maven build [message #1725788 is a reply to message #1725786] Mon, 07 March 2016 16:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
this works for me

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org.zzz</groupId>
	<artifactId>org.zzz</artifactId>
	<version>0.0.1-SNAPSHOT</version>


	<build>
		<plugins>


			<plugin>
				<groupId>org.eclipse.xtext</groupId>
				<artifactId>xtext-maven-plugin</artifactId>
				<version>2.9.2</version>
				<executions>
					<execution>
						<goals>
							<goal>generate</goal>
						</goals>
					</execution>
				</executions>
				<configuration>



					<sourceRoots>
						<sourceRoot>src/main/resources</sourceRoot>

					</sourceRoots>
					<languages>
						<language>
							<javaSupport>true</javaSupport>
							<setup>org.xtext.example.mydslb.MyDslBStandaloneSetup</setup>
							<outputConfigurations>
								<outputConfiguration>
									<outputDirectory>target/generated-sources/xtend/</outputDirectory>
								</outputConfiguration>
							</outputConfigurations>
						</language>
						<language>
							<javaSupport>true</javaSupport>
							<setup>org.xtext.example.mydsla.MyDslAStandaloneSetup</setup>
							<outputConfigurations>
								<outputConfiguration>
									<outputDirectory>target/generated-sources/xtend/</outputDirectory>
								</outputConfiguration>
							</outputConfigurations>
						</language>
					</languages>

				</configuration>
				<dependencies>
					<dependency>
						<groupId>org.xtext.example.mydsla</groupId>
						<artifactId>org.xtext.example.mydsla</artifactId>
						<version>1.0.0-SNAPSHOT</version>
					</dependency>
					<dependency>
						<groupId>org.xtext.example.mydslb</groupId>
						<artifactId>org.xtext.example.mydslb</artifactId>
						<version>1.0.0-SNAPSHOT</version>
					</dependency>
				</dependencies>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>org.zzz</groupId>
			<artifactId>org.zzz.modelsa</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
	</dependencies>
</project>


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolve cross references from a different DSL during Maven build [message #1725919 is a reply to message #1725788] Tue, 08 March 2016 14:00 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Hi Christian,

I tried your config but it doesn't generate anything unfortunately.

I created a sandbox with the same configuration as my original projects, it's attached to my comment.

Here's its layout:
- org.xtext.example.dsla
- org.xtext.example.dslb
- myservice: Uses DslA to generate something. The generated stuff and the DSL from which it was generated are included in the built jar.
- myclient: Uses DslB to generate something and relies on the MyService.dsla file, included in myservice.jar. In the current setup the build is successful but nothing is generated.

One important thing is that in GenerateDslB.mwe2 I had to use the absolute path of DslA's genmodel, otherwise I get that the path is unmapped. I don't know if this is the key to the current problem, but it's another unresolved issue of mine nevertheless.

The sandbox is configured to use Xtext 2.9.0.
Re: Resolve cross references from a different DSL during Maven build [message #1725921 is a reply to message #1725919] Tue, 08 March 2016 14:11 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Oops, I forgot to add myserivce as a dependency to the xtext-maven-plugin in the sandbox, but it still doesn't generate anything.

The missing part:
<dependency>
    <groupId>myservice</groupId>
    <artifactId>myservice</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>
Re: Resolve cross references from a different DSL during Maven build [message #1725943 is a reply to message #1725921] Tue, 08 March 2016 15:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
<sourceRoot>src/main/dsl/</sourceRoot>

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Resolve cross references from a different DSL during Maven build [message #1725960 is a reply to message #1725943] Tue, 08 March 2016 16:09 Go to previous message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
Oh... It works with your previously posted POM. Thank you very much!
Previous Topic:Different prefix for Special Character in RuleCall
Next Topic:Problem: Validator/Generator cannot navigate through AST/Index/ResourceSet from Unit-Tests
Goto Forum:
  


Current Time: Fri Mar 29 15:26:38 GMT 2024

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

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

Back to the top