This post answers the question from issue #5 on how to generate Java code from an Isis Script file in a Maven build.

For using Xtext-based languages in Maven builds, the Xtext project provides a dedicated Maven plugin - xtext-maven-plugin. Here a Maven user just adds the corresponding Xtext language artifact as a dependency to this plugin and defines the language-specific configuration. This configuration contains the name of the StandaloneSetup class and the output folder. If your project has a large classpath then you can also specify which jars to search for model files (via classPathLookupFilter) to speeding up your build.

<plugin>
	<groupId>org.eclipse.xtext</groupId>
	<artifactId>xtext-maven-plugin</artifactId>
	<executions>
		<execution>
			<goals>
				<goal>generate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<languages>
			<language>
				<setup>org.vaulttec.isis.script.IsisStandaloneSetup</setup>
				<outputConfigurations>
					<outputConfiguration>
						<outputDirectory>${project.build.directory}/generated-sources/isis</outputDirectory>
					</outputConfiguration>
				</outputConfigurations>
			</language>
		</languages>
		<classPathLookupFilter>.*isis.*</classPathLookupFilter>
	</configuration>
	<dependencies>
		<dependency>
			<groupId>org.vaulttec.isis.script.eclipse</groupId>
			<artifactId>org.vaulttec.isis.script</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
	</dependencies>
</plugin>

The language artifact of Isis Script org.vaulttec.isis.script is not available in Maven Central yet. In the meantime you have to checkout the Isis Script project from GitHub and install the language artifact in your local Maven repository via mvn install.

In order to let the Maven Java compiler pick up the generated Java code the corresponding output folder has to be added to the Maven projects list of Java source folders. This is done by using the build-helper Maven plugin.

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>build-helper-maven-plugin</artifactId>
	<executions>
		<execution>
			<goals>
				<goal>add-source</goal>
			</goals>
			<configuration>
				<sources>
					<source>${project.build.directory}/generated-sources/isis</source>
				</sources>
			</configuration>
		</execution>
	</executions>
</plugin>

A complete example can be found in the POM of the simpleapp example (part of the Isis Script GitHub project).