Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext maven plugin language order(Language generation order by xtext-maven-plugin)
Xtext maven plugin language order [message #1802957] Tue, 19 February 2019 16:12 Go to next message
Emerson Kopp is currently offline Emerson KoppFriend
Messages: 1
Registered: February 2019
Junior Member
Hello,

I'm working on the development of a language (B) that depends on some information generated in runtime by another language (A). So I need the generation of language A to occur before the generation of language B. I have a project that uses the xtext-maven-plugin configured with the two languages:

<plugin>
	<groupId>org.eclipse.xtext</groupId>
	<artifactId>xtext-maven-plugin</artifactId>
	<version>2.10.0</version>
	<executions>
		<execution>
			<id>generate-dsl-sources</id>
			<phase>generate-sources</phase>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<languages>
			
			<!-- Language A -->
			<language>
				<setup>com.example.AStandaloneSetup</setup>
				<outputConfigurations>
					<outputConfiguration>
						<outputDirectory>src/main/generated-sources/xtend/</outputDirectory>
					</outputConfiguration>
				</outputConfigurations>
			</language>

			<!-- Language B -->
			<language>
				<setup>com.example.BStandaloneSetup</setup>
				<outputConfigurations>
					<outputConfiguration>
						<outputDirectory>src/main/generated-sources/xtend/</outputDirectory>
					</outputConfiguration>
				</outputConfigurations>
			</language>
			
		</languages>
	</configuration>
	<!-- dependencies... -->
</plugin>


But the generation of these languages ​​by maven is performed in random order. Is there any way to ensure that the generation of language A is executed before the generation of language B?
Re: Xtext maven plugin language order [message #1850624 is a reply to message #1802957] Thu, 10 March 2022 16:30 Go to previous messageGo to next message
Simon Cockx is currently offline Simon CockxFriend
Messages: 18
Registered: October 2021
Junior Member
PING! I need this too.
Re: Xtext maven plugin language order [message #1850627 is a reply to message #1850624] Thu, 10 March 2022 18:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14353
Registered: July 2009
Senior Member
I assume you need to have a look at the code and or write your own version
but i fear the plugin reads all file at once.
so files generated by one dsl will never be read for the 2nd dsl
maybe you can configure the plugin twice


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Thu, 10 March 2022 21:09]

Report message to a moderator

Re: Xtext maven plugin language order [message #1851139 is a reply to message #1802957] Mon, 28 March 2022 18:12 Go to previous message
Edmundo López Bóbeda is currently offline Edmundo López BóbedaFriend
Messages: 27
Registered: October 2012
Junior Member
Hello,

You can do it as follows:

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>add-source-hello</id>
						<goals>
							<goal>add-source</goal>
						</goals>
						<phase>prepare-package</phase>
						<configuration>
							<sources>
								<source>${project.build.outputDirectory}/generated/xtext</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.eclipse.xtext</groupId>
				<artifactId>xtext-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>generate-hello</id>
						<goals>
							<goal>generate</goal>
						</goals>
						<configuration>
							<sourceRoots>
								<sourceRoot>${project.basedir}/src/main/java</sourceRoot>
								<sourceRoot>${project.basedir}/src/test/java</sourceRoot>
							</sourceRoots>
							<languages>
								<language>
									<setup>com.idiomaticsoft.dsl.hellogenn.HelloGenStandaloneSetup</setup>
									<outputConfigurations>
										<outputConfiguration>
											<outputDirectory>${project.build.directory}/generated-sources/xtext/</outputDirectory>
										</outputConfiguration>
									</outputConfigurations>
								</language>
							</languages>
						</configuration>
					</execution>
					<execution>
						<id>generate-txt</id>
						<goals>
							<goal>generate</goal>
						</goals>
						<phase>prepare-package</phase>
						<configuration>
							<languages>
								<language>
									<setup>com.idiomaticsoft.dsl.hello.HelloStandaloneSetup</setup>
									<outputConfigurations>
										<outputConfiguration>
											<outputDirectory>${project.build.directory}/generated-sources/xtext</outputDirectory>
										</outputConfiguration>
									</outputConfigurations>
								</language>
							</languages>
						</configuration>
					</execution>
				</executions>
					<dependencies>
						<dependency>
							<groupId>com.idiomaticsoft.dsl.hello</groupId>
							<artifactId>com.idiomaticsoft.dsl.hello</artifactId>
							<version>1.0.0-SNAPSHOT</version>
						</dependency>
						<dependency>
							<groupId>com.idiomaticsoft.dsl.hellogenn</groupId>
							<artifactId>com.idiomaticsoft.dsl.hellogenn</artifactId>
							<version>1.0.0-SNAPSHOT</version>
						</dependency>
					</dependencies>
			</plugin>


In the example. The com.idiomaticsoft.dsl.hellogenn.HelloGenStandaloneSetup is executed first and then the com.idiomaticsoft.dsl.hello.HelloStandaloneSetup language.

I wrote a blog post about it at: https://idiomaticsoft.com/post/2022-03-28-have-dsl-as-input-for-another/ with the full explanation and a working project.
Previous Topic:Bi-directional reference
Next Topic:Xtext & Build Loops
Goto Forum:
  


Current Time: Mon Oct 03 02:58:59 GMT 2022

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

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

Back to the top