Run MWE2 workflows for Xtext 2.0 in a Tycho build

I’ve been doing some work on the Zest build to make the MWE workflow (which generates a bunch of files from an Xtext grammar) part of the Tycho build. I guess I just couldn’t stand committing tons of changes after some very small tweaks to the grammar I did earlier today.

To hook the workflow into the Tycho build, I was basically able to use the info in the very good and detailed tutorial by Karsten Thoms. To make it work for our specific project setup and for the latest Xtext version I still had to tweak some minor things, so I thought I’ll do a quick writeup of what I have actually done to make it work. This assumes you already have an Xtext project and you’re already building with Tycho in general. If not, check out the tutorial mentioned above.

To add the MWE workflow to the Tycho build, all I had to do was add a plugin repository in the parent pom:

<pluginRepositories>
  <pluginRepository>
    <id>fornax-snapshots</id>
    <url>http://www.fornax-platform.org/archiva/repository/snapshots/</url>
    <snapshots><enabled>true</enabled></snapshots>
  </pluginRepository>
</pluginRepositories>

Add a plugin pointing to the MWE workflow file in the Xtext grammar project pom:

<build>
  <plugins>
    <plugin>
      <groupId>org.fornax.toolsupport</groupId>
        <artifactId>fornax-oaw-m2-plugin</artifactId>
        <version>3.3.0-SNAPSHOT</version>
        <configuration>
          <workflowEngine>mwe2</workflowEngine>
          <workflowDescriptor>src/parser/GenerateLang.mwe2</workflowDescriptor>
        </configuration>
        <executions>
          <execution>
          <phase>generate-sources</phase>
          <goals><goal>run-workflow</goal></goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

And define the Xtext grammar project source folder as a resource directory:

<build>
  <resources>
    <resource><directory>src</directory></resource>
  </resources>
</build>

When running mvn clean install, the MWE workflow now runs as part of the grammar project build.

About these ads

About this entry