Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtext DSLs ignored in Maven Multiple Modules Project
Xtext DSLs ignored in Maven Multiple Modules Project [message #1798225] Wed, 14 November 2018 07:52 Go to next message
Eclipse UserFriend
The DSL works within a simple/single maven project. The source folders for the DSLs are found, compiled and everything is working fine.

Within a multiple modules project in which you start the "clean package" from a different project, the xtext-maven-plugin doesn't seem to find any DSLs.

For the simplified example there are three projects:

company.mavenized.example.root (parent project for the dependencies etc)
company.mavenized.example.common (project that also contains the DSLs)
company.mavenized.example.target (project defining the modules etc)

Root Pom:
<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>de.company.product</groupId>
	<artifactId>example-root</artifactId>
	<version>1.0.0-SNAPSHOT</version>
	<packaging>pom</packaging>
	<name>mavenized root</name>

	<properties>
		<product-base-version>1.0.0-SNAPSHOT</product-base-version>
		<product-appgenerator-version>1.2.0-SNAPSHOT</product-appgenerator-version>
		<xtext-version>2.13.0</xtext-version>

		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<repositories>
		[...]
	</repositories>

	<pluginRepositories>
		[...]
	</pluginRepositories>

	<build>
		<plugins>
			<!-- java version festlegen -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.6.0</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<dependencyManagement>
		<dependencies>
			<!-- Appgenerator product-Base -->
			<dependency>
				<groupId>de.company.product</groupId>
				<artifactId>de.company.product.base</artifactId>
				<version>${product-base-version}</version>
			</dependency>

			<dependency>
				<groupId>org.eclipse.xtend</groupId>
				<artifactId>org.eclipse.xtend.lib</artifactId>
				<version>${xtext-version}</version>
			</dependency>
		</dependencies>
	</dependencyManagement>
</project>


Target Pom:
<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>

	<parent>
		<groupId>de.company.product</groupId>
		<artifactId>example-root</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<relativePath>../company.mavenized.example.root</relativePath>
	</parent>

	<artifactId>target</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<name>company.mavenized.example.target</name>

	<packaging>pom</packaging>

	<modules>
		<module>../company.mavenized.example.common</module>
	</modules>
</project>


Common Pom:
<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>

	<artifactId>company.mavenized.example.common</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>company.mavenized.example.common</name>

	<parent>
		<groupId>de.company.product</groupId>
		<artifactId>example-root</artifactId>
		<version>1.0.0-SNAPSHOT</version>
		<relativePath>../company.mavenized.example.root</relativePath>
	</parent>

	<properties>
		<src-gen-folder-name>generated</src-gen-folder-name>
		<xtend-src-gen-main>src/main/${src-gen-folder-name}/</xtend-src-gen-main>
		<xtend-src-gen-test>src/test/${src-gen-folder-name}/</xtend-src-gen-test>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
	</properties>

	<build>
		<plugins>
			<!-- maven-clean-plugin -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-clean-plugin</artifactId>
				<version>2.5</version>
				<executions>
					<execution>
						<phase>clean</phase>
						<goals>
							<goal>clean</goal>
						</goals>
						<configuration>
							<filesets>
								<fileset>
									<directory>${xtend-src-gen-main}</directory>
								</fileset>
								<fileset>
									<directory>${xtend-src-gen-test}</directory>
								</fileset>
							</filesets>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!-- build-helper-maven-plugin -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.12</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>${xtend-src-gen-main}</source>
								<source>src-gen-once</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.6.0</version>
				<configuration>
					<source>1.8</source>
					<target>1.8</target>
				</configuration>
			</plugin>
			<!-- xtext-maven-plugin -->
			<!-- appgenerator language config -->
			<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/xtext</sourceRoot>
						<sourceRoot>src/main/java</sourceRoot>
					</sourceRoots>
					<languages>
						<language>
							<setup>de.company.appgenerator.product.companyApplicationDescriptionStandaloneSetup</setup>
							<outputConfigurations>
								<outputConfiguration>
									<outputDirectory>${xtend-src-gen-main}</outputDirectory>
								</outputConfiguration>
							</outputConfigurations>
						</language>
					</languages>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>de.company.appgenerator.product</groupId>
						<artifactId>de.company.appgenerator.product</artifactId>
						<version>${product-appgenerator-version}</version>
					</dependency>
				</dependencies>
			</plugin>
			<!-- xtend-maven-plugin -->
			<plugin>
				<groupId>org.eclipse.xtend</groupId>
				<artifactId>xtend-maven-plugin</artifactId>
				<version>${xtext-version}</version>
				<executions>
					<execution>
						<goals>
							<goal>compile</goal>
							<goal>xtend-install-debug-info</goal>
							<goal>testCompile</goal>
							<goal>xtend-test-install-debug-info</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.eclipse.xtend</groupId>
			<artifactId>org.eclipse.xtend.lib</artifactId>
		</dependency>
		<dependency>
			<groupId>de.company.product</groupId>
			<artifactId>de.company.product.base</artifactId>
		</dependency>
	</dependencies>

	<repositories>
		[...]
	</repositories>

	<pluginRepositories>
		[...]
	</pluginRepositories>
</project>


If I execute "clean package" on the common project, everything works as expected.

But with a "clean package" on the target project, no dsl file is detected.

Regarding the output within the maven build:

Common-clean-package:
[INFO] --- xtext-maven-plugin:2.13.0:generate (default) @ company.mavenized.example.common ---
[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 D:\xyz\product\checkout_xtext\trunk\company.mavenized.example\target\xtext-temp\stubs
[INFO] Compiling stubs located in D:\xyz\product\checkout_xtext\trunk\company.mavenized.example\target\xtext-temp\stubs
[INFO] Nothing to compile. Stubs compilation was skipped.
[INFO] Installing type provider for stubs.
[INFO] Validate and generate.
[INFO] 
[INFO] --- xtend-maven-plugin:2.13.0:compile (default) @ company.mavenized.example.common ---


Target-clean-package:
[INFO] --- xtext-maven-plugin:2.13.0:generate (default) @ company.mavenized.example.common ---
[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 D:\xyz\product\checkout_xtext\trunk\company.mavenized.example\target\xtext-temp\stubs
[INFO] Compiling stubs located in D:\xyz\product\checkout_xtext\trunk\company.mavenized.example\target\xtext-temp\stubs
[INFO] Installing type provider for stubs.
[INFO] Validate and generate.
[INFO] Starting validation for input: 'example.productdsl'
[...-only output from the DSL while generating-...]
[INFO] Starting generator for input: 'example.productdsl'
[INFO] 
[INFO] --- xtend-maven-plugin:2.13.0:compile (default) @ company.mavenized.example.common ---


Big question is: How can I fix it? Did I miss something or is there a setting/config I need to provide for multiple module projects?
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798227 is a reply to message #1798225] Wed, 14 November 2018 08:28 Go to previous messageGo to next message
Eclipse UserFriend
i propose to remote debug into the plugin
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798233 is a reply to message #1798227] Wed, 14 November 2018 09:56 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Christian. This will be "fun" since I never debugged a maven-plugin itself. :D

Can you at least confirm that this is a mistake/error within my/our build and the Xtext-plugin is working in other multiple module projects as it is intented? That would lessen the range of possible issues/reasons.

Maybe someone knows of a working example of Xtext DSLs in a multiple module project? I guess that would help too.
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798240 is a reply to message #1798233] Wed, 14 November 2018 10:49 Go to previous messageGo to next message
Eclipse UserFriend
no i cannot. therefore your description is too vague. i have no idea what

<dependencies>
<dependency>
<groupId>de.company.appgenerator.product</groupId>
<artifactId>de.company.appgenerator.product</artifactId>
<version>${product-appgenerator-version}</version>
</dependency>
</dependencies>

does (and transitively contain)
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798246 is a reply to message #1798240] Wed, 14 November 2018 11:16 Go to previous messageGo to next message
Eclipse UserFriend
Christian Dietrich wrote on Wed, 14 November 2018 15:49
no i cannot. therefore your description is too vague. i have no idea what

<dependencies>
<dependency>
<groupId>de.company.appgenerator.product</groupId>
<artifactId>de.company.appgenerator.product</artifactId>
<version>${product-appgenerator-version}</version>
</dependency>
</dependencies>

does (and transitively contain)


I simply removed/changed the company related information with "company" or "product".
This is the simple dependency towards the xtext-project that describes the ".productdsl"

The DSL itself works fine as long as the maven build is used on the project where the ".productdsl" files are specified.

It is easy to reproduce with any working xtext project (that are containing dsls)

Create a root project,
add root project as parent to the dsl project,
create a second project containing the modules and set root as parent.

Build the second project with "clean package". Or rather first build the old xtext project to confirm that the code generation still works and afterwards try it again with the second project.
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798251 is a reply to message #1798246] Wed, 14 November 2018 11:54 Go to previous messageGo to next message
Eclipse UserFriend
please provide a github repo that reproduces.
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798252 is a reply to message #1798233] Wed, 14 November 2018 11:57 Go to previous messageGo to next message
Eclipse UserFriend
Karsten Wilken wrote on Wed, 14 November 2018 14:56

[...]

Can you at least confirm that this is a mistake/error within my/our build and the Xtext-plugin is working in other multiple module projects as it is intented?
[...]


I didn't intent to ask if my concrete maven build is correct but if Xtext works within the concept of multiple module projects. This seems to be a common scenario for Xtext DSLs (with maven). Therefore I assumed there would be working example(s).
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798255 is a reply to message #1798252] Wed, 14 November 2018 11:59 Go to previous messageGo to next message
Eclipse UserFriend
as i said: i need an example to understand what the problem is.
if you tell xtext-maven-plugin: here are my ten languages, use them to build it should work. if not its a problem.
if it is a user error or a bug i can only tell if i see it.
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798559 is a reply to message #1798255] Tue, 20 November 2018 07:58 Go to previous messageGo to next message
Eclipse UserFriend
Finally got the time to get the example working:

https://github.com/KarstenWilken/xTextForum

org.xtext.example.mydsl.parent - DSL project
xtextForum.* example build projects

To get the different results:

xtextForum.common clean package (finds DSLs)
and
xtextForum.target clean package (doesn't find DSLs)

[Updated on: Tue, 20 November 2018 07:59] by Moderator

Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798562 is a reply to message #1798559] Tue, 20 November 2018 08:06 Go to previous messageGo to next message
Eclipse UserFriend
clean package is not clean install. how should stuff be found if its not in the local maven repo.
will try to install parent into that

[Updated on: Tue, 20 November 2018 08:12] by Moderator

Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798563 is a reply to message #1798562] Tue, 20 November 2018 08:19 Go to previous messageGo to next message
Eclipse UserFriend
how can i find out if files are found?
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798565 is a reply to message #1798563] Tue, 20 November 2018 08:24 Go to previous messageGo to next message
Eclipse UserFriend
mvn clean install -Dmaven.repo.local=.m2 -f org.xtext.example.mydsl.parent/
mvn clean package -Dmaven.repo.local=.m2 -f xtextForum.common/
mvn clean package -Dmaven.repo.local=.m2 -f xtextForum.target/
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798566 is a reply to message #1798565] Tue, 20 November 2018 08:30 Go to previous messageGo to next message
Eclipse UserFriend
Sure, the dsl project needs to be build with clean install.

Within the build output the xtext-plugin displays the found dsl files:
[INFO] --- xtext-maven-plugin:2.14.0:generate (default) @ example.common ---
[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 D:\Projekte\EMO\checkout_xtext\trunk\xtextForum.common\target\xtext-temp\stubs
[INFO] Compiling stubs located in D:\Projekte\EMO\checkout_xtext\trunk\xtextForum.common\target\xtext-temp\stubs
[INFO] Installing type provider for stubs.
[INFO] Validate and generate.
[INFO] Starting validation for input: 'test.mydsl'
[INFO] Starting generator for input: 'test.mydsl'


[INFO] Starting validation for input: 'test.mydsl'
[INFO] Starting generator for input: 'test.mydsl'
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798569 is a reply to message #1798566] Tue, 20 November 2018 08:35 Go to previous messageGo to next message
Eclipse UserFriend
error is model dirs

<sourceRoots>
<sourceRoot>${basedir}/src/main/xtext</sourceRoot>
<sourceRoot>${basedir}/src/main/java</sourceRoot>
</sourceRoots>
Re: Xtext DSLs ignored in Maven Multiple Modules Project [message #1798572 is a reply to message #1798569] Tue, 20 November 2018 09:17 Go to previous message
Eclipse UserFriend
Thank you very much! It works as intended.
Previous Topic:Modifying an imported Xtext file programmatically
Next Topic:IQualifiedName references to object inherited from other DSL
Goto Forum:
  


Current Time: Tue Jun 17 16:59:57 EDT 2025

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

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

Back to the top