Wrapping an Eclipse PDE Build with Maven

Tagged:
A few months back our team at the office decided to buckle down and create an automated repeatable build for a new Eclipse RCP app we are working on - because it's the right thing to do. What follows is most of an article I wrote back then, and never got around to publishing here. This article isn't polished but if I don't hit submit right now, it will never see the light of day again - and I think it *might* help someone somewhere sometime even in less than perfect form, so here goes. (I updated the CODE and README for this project today - 01.07.2009, haven't really written a proper article yet, but README is better, and tested setup on multiple platforms, win32 and lin32. Check out the screen shot, Windows! Trying to make it nice for the people, since a few of you asked, even as much as I loathe said OS ;).) My life with PDE Build
Fortunately, Eclipse comes with a lot of support for automating builds in terms of the PDE (Plug-In Development Environment) project which includes an Ant based set of Eclipse Plug-In build tools. Even though Eclipse provides this, we normally use Maven for our builds, so we set out to find a way to use Maven to manage Eclipse PDE. Hence the saga began . . . PDE-Build Maven The task ended up falling to me after a few others made initial attempts, and didn't get as far as we had hoped. Enter the painful and overly complicated, but ultimately successful, process I used to build our RCP app from Maven (wrapping Eclipse PDE-Build). To start with I decided to look at existing Maven plugins for the job. Naturally enough, the others at our office that tried the build began here too - none of us could get anything resembling a working build. We tried 4 or 5 Maven plugins. A few were promising (including pde-maven-plugin over at Mojo) but all had various issues we couldn't get past. Then we tried other more specific projects like Tycho, and although again promising, these also stalled based on one roadblock or another and we just couldn't get a solid build. I thought this might all be hogwash and we had to be doing it wrong (which may still turn out to be the case, but we sure tried to do it right, and follow instructions where possible, maybe we will learn more about using the existing tools in the future). So I set out to find some blog posts or other documentation that had this nailed down. Surely this was a very common thing and others had pinpointed exactly what to do, right? Well, with the disclaimer that I am not an Eclipse RCP guy (and frankly don't *want* to be), I found existing information to be about as varied as possible, and often less than helpful. Oh there are many blog posts about different aspects of this (among the best are Eclipse PDE Build Tutorial by Lars Vogel and Dominik Zapf, Knol by Lucas Zapletal, and "troubleshooting" guides such as Troubleshooting an Eclipse PDE Build by Wong Liang Zan, and Common Eclipse Build Failures and Causes by David Carver), but there was nothing in my case that solved our problem in one shot. Also, along the way, while searching for articles on this topic, I found many many posts that seemed to echo what I was experiencing - this is harder than it should be, it takes WAY too long, it's very confusing for many people that attempt it (many people put it less tactfully than that, I am trying to be nice ;)). Ultimately I decided to punt AGAIN (after trying Maven plugins and other Maven approaches, and then using third party guides and tips) and just fall back to the *official* Eclipse documentation. I checked there to begin with, but the documentation there is sparse, and didn't relate to Maven, or to an outside of Eclipse build at all really (non-headless is where I was trying to end up), so I initially glanced at it and then tried to move on to blog posts and tutorials that I thought were more appropriate and more detailed. I was wrong. The documentation, while not great, should have always been my "lowest common denominator" starting point. The official docs helped, from there I at least got a command line build running via a headless Eclipse using the Ant tools built into PDE. Nevertheless, I was disappointed. I couldn't do this outside of a headless Eclipse environment (it's not just Ant, it's an Eclipse ant runner that brings in all the environment and OSGi stuff, etc), and it was just a sample and didn't include a lot of what I need in a real build (check out the code, manage the dependencies, run on multiple platforms, run without a bunch of custom setup on each machine, etc). I needed to next step up to a real project, and incorporate Maven. Long story short, I used the basic PDE stuff as a starting point and ended up with an approach that goes like this:
  • Create all the structure PDE needs with Maven via Ant
  • Checkout RCP plugins and stuff with Maven via Ant
  • For each RCP plugin we also have a Maven build - fork and run that on each
  • Run headless Eclipse build with Maven via Ant
  • The result - automated build that produces a zipped up RCP build (for multiple platforms in one shot)
A working sample of the build we now use (we use it on a much larger project with multiple plugins) is here: http://totsp.com/svn/repo/SamplePluginBuild/trunk/. This is complicated, more so that in it should be it seems (like I stated earlier), but once I got this setup working it has been doing the job well (and we don't have to worry about it anymore). One important (and potentially confusing) step I should note is that each of our plugins, such as the SamplePlugin used in this build has it's own separate Maven POM - and we fork and exec to run Maven on each during the outer Maven build. We are nesting Mavens. Our plugins do this because we don't like to check stuff in to a local "lib" folder and repeat it everywhere - so the plugin POM is used to pull in the dependencies before other build steps proceed. We also use these separate POMs when developing different plugins day to day to pull in and update the deps (outside of the big build). Also, on the build machine you still do need a local copy of Eclipse (the RCP enabled flavor "Eclipse for RCP/Plug-In Developers", must have the PDE build plugins, etc). The POM refers back to it as the property "eclipseLocation" and uses it for the build files and dependencies when running the headless PDE build. This sucks, but it has to be there (it can't just pull in X dependencies - not without herculean effort anyway). We are basically doing the standalone PDE Ant based build, we are just wrapping it all with Maven (to create the structure, check out the code, etc).
Jump back to now, rather than what I wrote a few months back (and didn't complete). Check out the README file in the SamplePluginBuild project for more information. Also, one last time, I know this article isn't complete or as detailed as it should be, but again, I just don't have time to clean it up at the moment and I don't want to just trash it either. If it helps it helps, if not, sorry. This build process is being used on a production RCP app at our shop now, and so far so good (as long as you aren't the one who has to set it up ;)).

Comments

Sample Plugin Build

Thanks for your efforts, I've checkout out your sample plugin build code. Yeah I'm just getting started with Headless builds of eclipse, trying to get my head wrapped around Tycho, seems that Tycho is new enough not to have much documentation or following yet.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.