atom feed3 messages in org.apache.maven.usersRe: Maven Newbie
FromSent OnAttachments
Hari KodungallurDec 5, 2002 9:25 pm 
Siegfried GöschlDec 6, 2002 2:45 am 
Brian EwinsDec 6, 2002 3:19 am.xml, .xml
Subject:Re: Maven Newbie
From:Brian Ewins (
Date:Dec 6, 2002 3:19:53 am
anthill-build.xml - 1k
build.xml - 11k

Hari Kodungallur wrote:

I am new to Maven. [...] Each module has an ant build file. I also have a master build file which is used to build all the modules, mainly during nightly build. [..] We don't want to move away from individual module ant build files. We would like to use Maven to manage all the individual ant build files (as a master build file, sort of) and in addition use the plug-ins available for the other tools to do code coverage and code checking for all modules.

I'm fairly new to maven too, but had similar issues to begin with. Whats below is just what I did.

(1) Is Maven the right tool to do this?

Not if you want to keep the individual ant build files. Maven gives you the most benefit if you are willing to stick to the maven directory layout, and only write a project.xml - there gives you the least to maintain in each module. If you try to keep a different directory structure and list of targets from maven's you'll find its like swimming uphill.

The question you need to answer is, why do you want to keep the ant files? If each project is truly different you can just add some of your ant tasks into the project's maven.xml; the only other reasons we have for keeping ant are that maven is still beta, and the level of IDE integration from maven, though we're happier with this now[1]

Going back to your 'master' build file - you seem to be using it both to provide a common set of goals/targets to projects, and to execute that common set of goals from a nightly build. I think those two functions would be better separated, into a file you 'include' from all your ant scripts, and a simpler 'master' script that just does the checkout-build-label cycle for nightlies. Have you read 'Ant in Anger'[2]? You could possibly even ditch the 'nightly' aspect in favour of a tool like anthill[3], CruiseControl[4], or the Gump[5].

If you went with maven, it takes the role of the included file - giving you access to all of maven's plugins from all of your projects - and the 'reactor'[6] is the thing that does 'master' builds.

(2) If yes, can somebody give me some HOWTOs and also sample project descriptors to do this kind of tasks? Anything closely related will be very helpful, as either the documentation on Maven's website is too little or too confusing to me.

Since I'm in the position of having some ant projects and some maven projects I want to build nightly (until we make the jump to maven only) I looked into setting up various tools to do the automated/nightly builds. As we're not on CVS, the Gump was out of the question for us; so I went with Anthill, and wrote an anthill-build.xml (attached) that I use for /all/ maven projects - it just executes a couple of maven goals. Its not ideal, but it lets me work with ant and maven side by side.

One caveat, there is a bug in maven preventing it returning an exit code[7], so anthill won't detect build failures; I had to patch my copy to fix this.

An alternative approach I tried was to write an ant script to do maven and/or ant builds in a similar manner to anthill. The idea was to write a multiproject build script which simply cycles over the projects to build, and for each calls a single project 'bootstrap' checkout-build-label script (attached), which in turn calls the project's actual build file via the correct tool. The attached script is again aimed at working with building ant and maven projects side by side, and doesn't address the issue of sharing targets between ant scripts.

However I should point out that I consider all of these to be sticking plaster approaches - I want to move /all/ of our projects across to maven as, despite its flaws, it is a vast improvement!


Thank you very much -Hari

[1] To integrate an IDE with a build tool, you mainly need the ability to parse error output, and for advanced features, access to the same classpath for code completion etc. Running maven with '-E' presents unadorned javac error messages, I've successfully worked with maven under XEmacs and netbeans by using just the error output; apparently integration with Eclipse and IntelliJ IDEA is even better. [2] [3] [4] [5]
[6] [7]