Much ado about scripting, Linux & Eclipse: card subject to change

2010-03-31

HOWTO: Build Plugin & Feature Projects, Then Run Their Unit Tests w/ Tycho :: GEF Example

Note that the instructions below are for Linux (or MacOSX). On Windows, your YMMV, but the process is the same.

1. Check out the entire source tree of your project from CVS, SVN, or Git into ~/build.

2. If needed, move plugins, features & test plugins into:

~/build/plugins/
~/build/features/
~/build/tests/

(Test features should go into features/ folder too.)

3. Install scala from http://www.scala-lang.org/downloads

4. Fetch genpom.scala and parent-pom.xml; save in ~/build or equivalent.

5. Tweak parent-pom.xml to suit your needs or use as-is.

6. Run this to generate pom.xml files for plugins, features, and tests:

cd ~/build/plugins/; scala ../genpom.scala
cd ~/build/features/; scala ../genpom.scala
cd ~/build/tests/; scala ../genpom.scala

7. Download Maven 3 from http://www.apache.org/dyn/closer.cgi?path=/maven/binaries/apache-maven-3.0-alpha-7-bin.tar.gz

8. Install Maven 3

sudo su; cd /opt; tar xvzf apache-maven-3.0-alpha-7-bin.tar.gz
ln -s apache-maven-3.0-alpha-7 maven3

9. For convenience, alias mvn3 to the new maven:

alias mvn3='/opt/maven3/bin/mvn 2>&1 clean install | tee buildlog.latest.txt'

10. Build the plugins, features, and finally tests:

cd ~/build/plugins/; mvn3
cd ~/build/features/; mvn3
cd ~/build/tests/; mvn3
Look in ~/build/plugins/org.eclipse.*/target/ for generated jars.
Look in ~/.m2/repository/org/eclipse/* for published jars.
To automate steps 6 and 10, you can run this script in the ~/build/ folder:
#!/bin/bash
for f in plugins/ features/ tests/; do \
  cd $f; scala ../genpom.scala; \
  /opt/maven3/bin/mvn 2>&1 clean install | tee buildlog.latest.txt; \
  cd ..; \
done

(The above blog is also posted here.)

2 comments:

Eugene Kuleshov said...

Instead of the last script you should be able to use Maven's feature, like:

mvn -r clean install

or with includes

mvn -r -Dmaven.reactor.includes=maven-eclipse-plugin/pom.xml,maven-idea-plugin/pom.xml
clean install

What's left is to wrap that Scala script into a Maven plugin, so you could reuse it directly too.

nickb said...

Even better, I've rewritten the scala script as an Ant script (genpom.xml) so that I can use Ant to bootstrap maven3, gen the pom files, and run maven recursively (build.xml). I'll post more details when I have these scripts sufficiently refactored & tested for use outside JBoss Tools.