Jul 10

Eclipse is a great IDE for developing any kind of Java code, e.g. Rich Client (RCP), Web or standalone applications. However, when a project is built using any IDE (yes, there are others – e.g. Netbeans or IntelliJ IDEA), there may be some dependencies towards the chosen tool when it comes to compiling and packaging the code. This doesn’t matter too much as long as there is no requirement to automate the build process. This will happen, as soon as you decide to set up Continuous Integration for your project.

In many cases, Ant is the tool of choice for automating the build process. As far as I know, Netbeans already uses Ant as build tool by default. Eclipse has its own way of describing the project configuration (source/binary folders, required libraries etc.) with files like “.project” and “.classpath”. The naive approach for building an Eclipse project with Ant would be to duplicate all the information and write a separate Ant build file that does all the work and is independent of an Eclipse instance. There are several disadvantages that come along with this approach:

  1. Inconsistencies may occur whenever a new library is added or the structure of the project changes in a significant way (e.g. a new source folder is introduced) => the build file has to be updated manually when the build fails.
  2. There is no real guarantee that both the Eclipse and the Ant build produce the same output => Problems may not be visible until runtime tests are performed.

So what could be a more elegant solution? Of course, to use the information for the build that is contained in the Eclipse project artifacts already. The only tool I found up to now that does right this is ant4eclipse. Basically, it defines some Ant tasks that enable the following actions (from ant4eclipse’s website):

  • Setup classpathes as defined in Eclipse’s .classpath-file
  • checkout complete workspaces as it’s possible with the Team Project Set feature of eclipse
  • run your Java applications as you have defined them in an Eclipse Launch Configuration

This avoids the redundancy and leverages the information that is already present as soon as the project compiles in Eclipse. To be honest, I haven’t evaluated ant4eclipse yet, but I probably will as soon as the next Continuous Integration project will start. Seriously, who would like to write dozens of Ant files to do the work that Eclipse already does?

Another interesting project that seems to focus solely on Eclipse plugins, features and RCP apps is Pluginbuilder. The tutorial movie looks really impressive. The homepage says that Pluginbuilder consists of two parts:

  • An Eclipse plug-in allows to configure the build in the project’s workspace and run the build locally
  • Then the configuration can be uploaded to the server platform where the build can be scheduled

That’s a nice alternative to the manual configuration of the Eclipse headless build and integration with e.g. CruiseControl. Haven’t evaluated that one neither, but this is definitely a very interesting and promising tool for Eclipse plugin and RCP development which I can imagine may be indispensable once you are used to it.

Which other tools for Eclipse build automation do you know?

One Response to “Tools for Eclipse build automation”

  1. Gábor Lipták Says:

    Check out this opensource eclipse plugin, and create your builds with eclipse without extra effort. Home: http://code.google.com/p/headlesseclipse/