Thursday, July 21, 2005

Maven catch-22 with multiproject builds

Maven's multiproject plug-in is a very useful tool on a large project that's been organized into several sub-projects. Using the dependencies the reactor figures out the correct order in which to build the entire project. However Maven gets in its own way when doing such builds. Here's how:

Consider a multiproject with sibling sub-projects that are interdependent. Having been bitten one too many times for not doing so, I have become fastidious about maven cleaning before every build. Just as with any other plugin, when you invoke clean, Maven checks the dependencies. However, when this happens the first time the multiproject is being built, the dependencies cannot satisfied and so the build quits with a failed dependency.

If you are wondering why get so anal about cleaning and that it isn't needed before the first-ever build, consider setting up your builds to be managed by CruiseControl. That's an automated process and needs to be given the goal(s) that must be executed at every build cycle.

So, the only solution I know is to perform a one-off build manually without a clean and then let CruiseControl loose. Can you suggest a better alternative?

Speaking of cleaning and multiprojects, why doesn't multiproject:clean clean the root directory? Why do I have to maven clean multiproject:clean?

Tweety thoughts

    follow me on Twitter