The Scala Refactoring project currently uses a rather crude hand-written ant build file; it compiles and runs tests. What it doesn’t do is creating a proper OSGi bundle, which I need if I want to do proper releases and integrate it into the Scala Eclipse IDE. Most of my colleagues are using PDE build, but from what I’ve heard, Buckminster or Maven/Tycho are the way to go.

Buchminster looks rather complex to me, so I went with Maven, even though I had no prior experience with it. Now, a few hours later, I have a Hello World plug-in written in Scala and a bunch of poms that build everything I want, even an update site!

Tycho needs Maven 3, which hasn’t been released yet, so I downloaded the latest alpha build and created an alias that pointed to the mvn binary.

I started with Mattias Holmqvist’s Blog where he explains how to create the initial Maven configuration and an OSGi bundle in Eclipse (I created a Hello World Plug-in Project). Now, we don’t want to have a Java plug-in but one written in Scala, so I added the Scala Nature to the project and re-wrote the two generated files in Scala.

To add Scala functionality to my pom, I followed the Eclipse Scala Maven Integration wiki. I also had to add the Scala Eclipse Plug-in nightly build update site to my list of repositories so Maven could resolve the scala.library dependency the project has.

    <repository>
       <id>scala eclipse nightly</id>
       <layout>p2</layout>
       <url>http://download.scala-ide.org/scala-eclipse-toolchain-osgi-2.9.1.final/</url>
    </repository>

Because I apparently didn’t follow Maven’s source layout, I had to explicitly specify the source directory via:

<sourceDirectory>${basedir}/src</sourceDirectory>

Adding the update site and feature projects was a peace of cake when following this tutorial (scroll to Creating an Update Site / P2 repository) from the Tycho project.

I’ve put the whole project on GitHub so you can try it yourself. And remember, this is my first day with Maven, so if I could make the poms even smaller or more idiomatic, please tell me. Or even better, just fork my code!

Next I’m going to find out how to run unit tests and how the integration in Hudson works, and then I can migrate the Scala Refactoring project and delete a build.xml file.

Update April 2012: I’ve updated the sample repository to the latest versions of Scala, Eclipse and Maven-Tycho.

Update July 2012: Updated the sample repository to the use Scala 2.9.2, Eclipse Juno and Tycho 0.15.0.