I’ve helped setup quite a few Maven Tycho builds for people as of late, with more requests coming in. Personally, I’ve had quite a bit of experience working with Tycho-based builds as being one of the first early adopters with the EGit and JGit projects at Eclipse. At that time, Tycho was pretty rough around the edges but I’m pleased to report I believe now Tycho to be one of the best, if not the best option for building Eclipse/OSGi related artifacts. Sure, it’s not perfect but it’s pretty damn good now. Furthermore, there are even large projects like Mylyn at eclipse.org that have moved to Tycho to manage their whole build if you need further proof.
One of the common complaints from folks within the eclipse.org ecosystem is how difficult it is to setup build. In the past, we had the Athena Common Build project at eclipse.org with some success. Athena helped many projects get off the ground when it comes to building and publishing their artifacts. However, it still suffered the drawbacks of PDE Build based systems when it came to debugging, customizing and extending the build system. For example, if you wanted to integrate with Hudson, add FindBugs to your build or run SWTBot unit tests, you suffered quite a bit. Well, I’m happy to report that Maven Tycho helps quite a bit with these customization issues. To help alleviate some of the pain we’re experiencing with build at eclipse.org, I decided to put up sample Maven Tycho project for people to look at and refine. I’m calling the effort Minerva as I think it plays nicely with what was done in the Athena project (Minerva is the Roman equivalent of Athena and the word Maven is in Minerva!).
The goal of the Minerva project would be to get a well documented sample build for eclipse.org projects. I can even envision a future when a new eclipse.org project comes around and they get a build already generated for them and hooked up to hudson.eclipse.org! I think once you have something working and it’s well documented, it becomes pretty easy to expand as you add new features.
To get started, I’d take a look at what is on the wiki already. If you want to play with code, ensure that Maven 3 is installed and then do a quick clone.
git clone git://github.com/caniszczyk/minerva.git
mvn -Dskip-ui-tests=true clean install
Once you do that, you should notice a p2 repository (update site) generated in the update site project’s target/site folder. To sweeten the deal, if you have Hudson (Jenkins) installed anywhere, you can configure it quickly to build the code base.
Remember how long something like that took before? In reality, Tycho isn’t that complicated to setup.
In Maven, the parent pom.xml serves as the central point on adding things to the build. It’s also generally the most complicated piece of the build as it contains information that is shared by children pom.xml files. The first part of the parent pom.xml contains identifying information:
...
<groupId>org.aniszczyk.minerva</groupId>
<artifactId>minerva-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Minvera Parent</name>
...
The second part contains profile information and where to get dependencies.
<properties>
<tycho-version>0.10.0</tycho-version>
<platform-version-name>helios</platform-version-name>
<eclipse-site>http://download.eclipse.org/releases/${platform-version-name}</eclipse-site>
<wikitext-site>http://download.eclipse.org/tools/mylyn/update/weekly</wikitext-site>
<swtbot-site>http://download.eclipse.org/technology/swtbot/${platform-version-name}/dev-build/update-site</swtbot-site>
</properties>
<profiles>
<profile>
<id>platform-helios</id>
<activation>
<property>
<name>platform-version-name</name>
<value>helios</value>
</property>
</activation>
<properties>
<eclipse-site>http://download.eclipse.org/releases/helios</eclipse-site>
<platform-version>[3.6,3.7)</platform-version>
<swtbot-site>http://download.eclipse.org/technology/swtbot/helios/dev-build/update-site</swtbot-site>
</properties>
</profile>
<profile>
<id>platform-indigo</id>
<activation>
<property>
<name>platform-version-name</name>
<value>indigo</value>
</property>
</activation>
<properties>
<eclipse-site>http://download.eclipse.org/releases/indigo</eclipse-site>
<platform-version>[3.7,3.8)</platform-version>
<swtbot-site>http://download.eclipse.org/technology/swtbot/indigo/dev-build/update-site</swtbot-site>
</properties>
</profile>
</profiles>
...
<repositories>
<repository>
<id>helios</id>
<layout>p2</layout>
<url>${eclipse-site}</url>
</repository>
<repository>
<id>swtbot</id>
<layout>p2</layout>
<url>${swtbot-site}</url>
</repository>
<repository>
<id>wikitext</id>
<layout>p2</layout>
<url>${wikitext-site}</url>
</repository>
</repositories>
What’s cool about setting up these repositories and profiles is that we can easily switch the build to run against Helios or Indigo repositories. If you want to run Indigo, simply set -Dplatform-version-name=indigo and you’re good to go. You could even setup multiple hudson jobs that build against various Eclipse releases if you want to ensure everything works properly.
The third part lists the modules (e.g., features, plug-ins) that are part of the build:
<modules>
<module>org.aniszczyk.minerva.core</module>
<module>org.aniszczyk.minerva.ui</module>
<module>org.aniszczyk.minerva-feature</module>
<module>org.aniszczyk.minerva.source-feature</module>
<module>org.aniszczyk.minerva-updatesite</module>
<module>org.aniszczyk.minerva.tests.core</module>
<module>org.aniszczyk.minerva.tests.ui</module>
</modules>
Each of those modules has a simple pom.xml that tells Tycho what type of project it is (think feature or plug-in). You should be able to piece things together by looking at the documentation on the wiki. Let me know if you have any questions and please feel free to add anything. My plan is eventually to get things up to shape so the code could live at eclipse.org and get things up to a point where a Maven archetype could be built and used to generate new projects.
Thoughts? Also, if you’re an eclipse.org project and interested in moving to Tycho, feel free to contact me and look at the example.