Using Maven Tycho

Spoofax project can be built continuously using a combination of Maven, Tycho and Ant. Using Maven should make it easy to run it in a continuous build server like Hudson. We use the same techniques described here in our continuous builds on Hydra.

Make sure you have the following software installed:

  • Maven 3.0
  • Ant
  • Eclipse with Spoofax installed

For this example we assume you have installed eclipse in $ECLIPSE.

This description is based on the following Nix expression we use in our continuous builds:

Installing Spoofax from command-line

You can install Eclipse and Spoofax like described here. However, in a continuous build/integration setting it is sometimes useful to be able to perform these actions from the command-line. Note that this script uses the Spoofax unstable update site.

cd $ECLIPSE

# remove vm args
sed -i 's|-Xms[0-9]*m||' eclipse.ini
sed -i 's|-Xss[0-9]*m||' eclipse.ini
sed -i 's|-Xmx[0-9]*m||' eclipse.ini
sed -i 's|-XX:MaxPermSize=[0-9]*m||' eclipse.ini
sed -i '/^$/d' eclipse.ini
perl -pi -e "s/^\r\n//" eclipse.ini

# add own default vmwargs
echo "-Xms256m" >> eclipse.ini
echo "-Xss8m" >> eclipse.ini
echo "-Xmx1024m" >> eclipse.ini
echo "-XX:MaxPermSize=256m" >> eclipse.ini
echo "-server" >> eclipse.ini

# install spoofax
ALL_SITES="http://www.lclnet.nl/update/unstable"
java -Xmx512m -jar plugins/org.eclipse.equinox.launcher_*.jar  \
     -application org.eclipse.equinox.p2.director \
     -metadataRepository $ALL_SITES \
     -artifactRepository $ALL_SITES \
     -installIU org.strategoxt.imp.feature.group \
     -data ../data \
     -consolelog

Setting up Maven

Create a directory with the editor plugin project, feature project and update site project in it.

Then issue the following command (replace version and groupId with something appropriate) to generate the maven pom.xml files:

mvn org.sonatype.tycho:maven-tycho-plugin:generate-poms -Dversion=1.0-SNAPSHOT -DgroupId=mygroup -Dtycho.targetPlatform=$ECLIPSE

If you want to run tests, like JUnit tests, make sure you add org.junit4 to your plugin dependencies and MANIFEST.MF. If your tests reside in your main plugin, you will need to edit the generated pom.xml file of that plugin. Replace,

  <packaging>eclipse-plugin</packaging>
by,
  <packaging>eclipse-test-plugin</packaging>

If you have your tests in a seperate plugin which name ends with tests, Tycho should recognize this and change the packaging element for you.

Running ant builds

Before running Maven you need to use build.main.xml of the Spoofax project(s) to generate some code/files that spoofax normally generates automatically from Eclipse (parsetables, java code from stratego, etc.)


export LOCALCLASSPATH="utils/aster.jar:utils/make_permissive.jar:utils/sdf2imp.jar:utils/strategoxt.jar"
export ANT_OPTS="-Xss8m -Xmx2048m"
export PATH=$PATH:$ECLIPSE/plugins/org.strategoxt.imp.nativebundle_*/native/linux/

for d in */build.main.xml ; do
  cd `dirname $d`
  mkdir -p utils 
  cp -Rv `find $ECLIPSE -name strategoxt.jar` utils/
  cp -Rv `find $ECLIPSE -name aster.jar` utils/
  cp -Rv `find $ECLIPSE -name sdf2imp.jar` utils/
  cp -Rv `find $ECLIPSE -name make_permissive.jar` utils/
  ant -f build.main.xml -Declipse.spoofaximp.jars=utils all
  cd ..
done

Running Maven build

When this is done, the project can be built using:

mvn package -Dtycho.targetPlatform=$ECLIPSE -e

If this is done successfully, you should have an update site available in your update site project directory.

If you would like to run the testsuites perform:

mvn integration-test -Dtycho.targetPlatform=$ECLIPSE -e

Revision: r1.1 - 03 Jan 2011 - 08:34 - RobVermaas
Spoofax > WebLeftBar > Documentation > ContinuousBuildingSpoofax
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback