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.)

2010-03-28

Dash Athena: Post-EclipseCon Wrap-Up

Updates to Athena since Feb 2010

Ease of use

  • You can now run buildExtra.xml#extraPackaging via build.steps=buildExtra rather than requiring build.steps=buildZips.
  • Publishing support will improve thanks to bug 306854... anyone want to contribute to writing a Hudson job, please feel free!

Packaging Support

  • bug 306300 Athena removes .jar files and only contains pack 200 files in update site - new default setting (keep both artifact types) is removeUnpackedJars=false, but can revert to old behaviour (and smaller update site) with removeUnpackedJars=true
  • bug 307016 SDK and Runtime zips produced with buildZips target are missing {notice,epl-v10}.html files; if root files exist they will now be copied into the SDK, Runtime, Examples zips; ${allZip} will also include this so it can be copied from there too (custom packaging in buildExtra.xml#extraPackaging task)

Testing Support

  • bug 296352 Can't connect to vnc server - fixed using Xnvc option in Hudson job and improvements to testLocal task

Publishing Support

  • bug 302170 Work around Hudson's missing lastS*Build folders - promote.xml will now recurse into Hudson job tree looking for correct build to publish
  • Publishing support will improve thanks to bug 306854... anyone want to contribute to writing a Hudson job, please feel free!

Bug Fixes

  • bug 304800 Temporary regression caused by adopting new build.xml script with too-aggressive cleanup default
  • bug 307016 SDK and Runtime zips produced with buildZips target are missing {notice,epl-v10}.html files; if root files exist they will now be copied into the SDK, Runtime, Examples zips; ${allZip} will also include this so it can be copied from there too (custom packaging in buildExtra.xml#extraPackaging task)

Documentation & Branding

  • bug 272723 Logo design contest for Athena under way: vote early, vote often!

2010-03-24

I'm in love with Tycho 0.8 and Maven 3

Monday:

Signed up for GitHub, downloaded apache-maven-3.0-alpha-7-bin.tar.gz, and built Tycho from source. Took a bit of path wrangling (namely figuring out that maven runs based on current directory), but it built and most of the tests passed. Not bad for my first day ever using Maven.

# First download Maven3 and unpack into /opt/
export MAVEN_OPTS="-Xmx512m"
export TYCHO_TARGET_PLATFORM=/home/nboldt/eclipse/35clean/eclipse
mvn=/opt/maven/bin/mvn
$mvn clean install -e -V -Pbootstrap-1
$mvn clean install -e -V -Pbootstrap-2 -Dtycho.targetPlatform=$TYCHO_TARGET_PLATFORM
$mvn clean test -e -V -Pits -Dtycho.targetPlatform=$TYCHO_TARGET_PLATFORM

The really confusing part was "what now? what did I just build? And how do I use it?" Answer: You can now run maven3 from .../sonatype-tycho/tycho-its/target/apache-maven-3.0-alpha-7/bin/mvn


Tuesday:

Attended the Sonatype-sponsored Tycho Build Workshop, and amazed Pascal by saying good things about Tycho and Maven3. Apparently I'm known to complain about all things p2, despite my numerous blogs and wiki contributions touting its success and usefulness. Also installed m2eclipse to see how effective the pom editor is.

During the workshop, I got the following JBoss Tools projects to build: jmx, archives, as, flow, jbpm3/4, drools, bpel, smooks, common. That's nearly half our projects! Thanks to Jason and Igor for their invaluable assistance.

The reason it was so easy was that Max had already created a scala script to generate all the pom.xml files we need to build JBoss Tools, and a parent-pom.xml on which those tiny pom.xml files depend. (For me as a Maven noob, not having to think at all about creating poms made this transition a no-brainer. Speaking of no-brainers, my slides from Monday's talk about Dash Athena and Zombies are here (PDF).

As an added bonus, Tycho, being more strict than PDE, exposes missing information in MANIFEST.MF files such as dependencies on plugins. PDE-based builds are apparently more forgiving because they generally include more crap than is actually needed in the target platform against which the build runs; Tycho builds against what you tell it you need. So, the mavenification of JBoss Tools will actually cause us to have better described plugins, and therefore make them easier to build anywhere. I'm very impressed so far.

Unlike Dash Athena which needs to be told all the IUs (features/plugins) against which your project needs to build, Tycho determines this information from your manifests, so the information need not be duplicated.

I still need to look at how to build update sites from the output of a Tycho build, and how to hook in SWTBot/JUnit4 tests. I have a suspicion this may be handled using Buckminster tools such as their Aggregator, or my own custom Ant hackery using the SWTBot wiki docs. Time will tell.


Wed

This morning on a whim I decided to see if I could port Max's scala script (aside: I've never seen scala before yesterday) to generate pom.xml files for EMF or GEF. Success! With some minor tweaks, I've managed to build GEF 3.6 into my local maven repo (~/.m2). Obviously there's more to be done here... but damn, this is easy.

2010-03-05

Beyond CVS 0.8.9 Released!

It's true that the shoemaker's children often go shoeless; so to my little Sourceforge project, Beyond CVS/SVN - maintained tirelessly over the years by Chris Callendar - has had to wait *years* to finally get its own update site.

Sad, I know. But thanks to a recent breakthough in being able to insert associate sites into p2 repo metadata, you can now install Beyond CVS/SVN without having to hunt down Subclipse or Subversive's update sites.

Here's the new site: http://beyondcvs.sourceforge.net/update/0.8.x. If you point Eclipse at it, you can install the features therein. If you point a browser at it, you can see instructions for how to do the install. And if you want an offline install, here's the zip: org.eclipse.externaltools-Update-0.8.9.v201003051612.zip (README).

2010-03-04

Athena: p2 repos w/ associate sites

Want to insert associate update sites into your user's Eclipse when they go to install your features from an update site/zip? With an Athena build this is now a trivial exercise. For example... say you're building a plugin which supports integration with Subclipse or Subversive. In a traditional install from an SDK or runtime zip, you'd unpack into eclipse/, and wonder why the new plugins didn't work. In the new p2 install world, you point Eclipse at the update site or zip, and are told that you cannot install the SVN integration because missing requirements cannot be found. So you hunt down the required sites, add them to Eclipse, and try again; this time you are allowed to install the new features. To improve the ease of use for the end user, Athena now allows you to define associate.sites in your build.properties. If this property is set, URLs will be added into your p2 repo's metadata and Eclipse will automatically add those sites when it scans your zip or site. No more manual copy+paste from documentation needed!

associate.sites=\
http://subclipse.tigris.org/update_1.6.x,\
http://download.eclipse.org/technology/subversive/0.7/update-site/,\
http://community.polarion.com/projects/subversive/download/eclipse/2.0/update-site/
And, of course, you can reuse these sites when resolving dependencies against which to build or test:
repositoryURLs=\
http://download.eclipse.org/releases/galileo/,\
http://download.eclipse.org/athena/repos/eclipse-Update-3.5.2-201002111343.zip,\
http://download.eclipse.org/eclipse/updates/3.5/,\
${associate.sites}

IUsToInstall=org.eclipse.sdk.feature.group+org.eclipse.sdk.ide+\
org.eclipse.team.svn+org.eclipse.team.svn.core+org.eclipse.team.svn.ui+\
org.tigris.subversion.subclipse.core+org.tigris.subversion.subclipse.ui