I have looked into building Neoclipse using Maven, but at the moment I'm not convinced there are more advantages then disadvantages in this case. Building Eclipse plugins and products has quite many quirks. With increasing use of product configuration options, the number of build quirks increases as well.
There seems to be no really automated build system for Eclipse plugins/products, even when using maven you have to install and update the dependencies manually (the Eclipse artifacts are not deployed to a maven repository).
Sonatype is busily working to address these gaps, and we already have some solutions you can use to start building your Eclipse plugins in Maven. Igor Fedorenko has been working on Tycho and Maven to create a system to facilitate OSGi and Eclipse development in Maven, and m2eclipse is currently built using Tycho. To prove that Tycho is a viable path for build the Neoclipse plugin, I took some time yesterday to generate Maven pom.xml files with Tycho and build an update site for Neoclipse.
The general idea of Tycho is that it acts as a bridge between Maven and OSGi. It supports a number of usage scenarios and is under active development. It can be used in a manfiest-first mode which builds a Maven POM from an OSGi manifest and it can also be used in a pom-first mode in which Tycho is responsible for generating an OSGi manifest from a Maven POM. Future plans include the ability to build a project usin Maven/Tycho without requiring the presence of a Maven POM, and there is active work under way to allow Nexus Maven repository manager to interact with Eclipse update sites and p2 repositories, that would allow Tycho to consume artifacts from those repositories. If you are looking for a more in depth explanation of Tycho, check out the Tycho Project Overview.
If you are looking for a solution to automate Eclipse builds with Maven, look no further, Tycho is your answer. In this post, I'm going to walk you through the process of configuring a Maven build for a real Eclipse plugin. This process involves the following, high-level steps:
At this point in the development of Tycho, you'll have to point the system at an installation of Eclipse, your targetPlatform. Let's get started.
Tycho currently builds Maven pom.xml using a local installation of Eclipse which should contain the Plugin Development Environment (PDE) and other Eclipse components your specific plugin depends on. Future versions of the Tycho product will likely interrogate remote p2 repositories and Eclipse update sites, but for now we have to configure a local Eclipse Target Platform with the necessary components. For this particular example, you'll need to install Eclipse 3.4 and download a few plugins that the Neoclipse plugin depends upon. For more information about what Neoclipse requires, see the Neo4J Wiki Page for Neoclipse. These steps are also needed when you need to work with Neoeclipse code using Eclipse PDE. You need to:
I'm on a Mac, so I usually install my eclipse distribution in /Applications/eclipse. For the remainder of this document, if you see /Application/eclipse, you should substitute your own eclipse installation directory.
At this point, you have Eclipse installed and configured with the necessary plugins to build the Neoclipse plugin. Now you need to download and configure Tycho. Tycho contains a development version of Maven 3.0 that has been extended to allow for Tycho to interact with the the OSGi components and format of the plugins directory of your Eclipse plugin. In the future versions you could use regular Maven 3.0 and use Tycho as any other Maven plugin.
Once Tycho is configured, you are ready to generate Maven POMs from your Eclipse plugin.
The demo script for Tycho uses a contrived a demo project called tychodemo.zip which contains a simple Eclipse plugin. I wanted to demonstrate that Tycho is ready to be used today with a real Eclipse project. This project is the Neoclipse plugin for Eclipse that allows users to interact with a Neo4J database in the Eclipse IDE.
At this point, you'll have pom.xml files in all of your plugins and at the top level. Tycho has generated a multi-module Maven project that references components in your targetPlatform, specified using “tycho.targetPlatform” property on the command line. Tycho doesn't need Eclipse to be running, all it needs is access to the Eclipse directory so that it can resolve components such as the Eclipse Plugin SDK at the GEF plugin installed in the previous section.
To build the update site, run: ~/programs/tycho/bin/mvn package -Dtycho.targetPlatform=/Applications/eclipse You should then have an update site in ./org.neo4j.neoclipse.updatesite/target/site
To avoid specifying tycho.targetPlatform property every time, it could be added to your settings.xml. For example:
... <profiles> <profile> <id>tycho.default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <tycho.targetPlatform>/Applications/eclipse</tycho.targetPlatform> </properties> </profile> </profiles> ...
UPDATE (9:21 AM CST): Eugene Kuleshov just sent in a bunch of edits and improvements which were incorporated. Removed the section about adding the repository as it should already be in the public group hosted on Sonatype's Nexus repository.