[SOLVED] Resolve cross references from a different DSL during Maven build [message #1725763] |
Mon, 07 March 2016 13:39 |
Tam Gom 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 #1725775 is a reply to message #1725765] |
Mon, 07 March 2016 14:58 |
Tam Gom 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 #1725788 is a reply to message #1725786] |
Mon, 07 March 2016 16:26 |
|
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
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05072 seconds