James Strachan's Weblog
Ramblings on Open Source, Java, Groovy, XML and other geeky malarkey
        

why I use Maven

For me the truly compelling reasons for using Maven are as follows...

Once you describe what your dependencies are, Maven will pretty much automatically build and test your code, (properly instrumenting your jars' manifest of course) downloading any jars required to build your code from one or more remote repositories into a local repository.

Maven will also build your entire website packed with oodles of useful reports, javadoc, cross referenced source code, unit test reports, style check reports, (optional clover test coverage reports).  Even better, by typing

maven site:deploy

It will build the site and deploy it on your website (internet, intranet etc) for you!

maven dist

Will create a binary distribution, including all the documentation, and deploy it for you too!

e.g. checkout this example site. There's an example here of the different reports. Essentially the whole 'Project Documentation' section is generated by Maven for you - e.g. a full list of real dependencies used to build your system or the development team details and contacts.

All of the above are pretty much my core reasons for using Maven. Here's a few other neat things I really like about Maven...

The use of a local repository makes it easy to work on several related projects; I can try installing a personal version of a certain project via

maven jar:install

which will build a project and install its jar in the local repository so that another project can build against it. No more messing around manually copying jars around.

Other handy things are the test:ui goal to run a Swing TestRunner or test:single and test:match for running individual unit tests or a pattern match of unit tests.

Then there's the eclipse, idea and jbulder plugins to automatically create project files for your build, with all the correct class & source paths. Oh and the ability to create Ant or Gump builds. I won't even get into all the various plugins for working with XDoclet or WARs or Cactus or web servers or JavaCC etc.

what does Maven do that I can't do in Ant?

Maven doesn't do anything that you can't do yourself, by hand in Ant.

The difference is Maven has done it already for you. i.e. it automates common tasks so you don't have to write or maintain your own Ant build.xml files

e.g. in Ant you have to hack your build.xml files on every project you have to add features like, test:ui to run the Swing JUnit TestRunner.

In any Maven enabled project you just type

maven test:ui

i.e. Maven has prebuilt plugins or wizards, already for you to use. You don't need to mess with Ant tasks to use these on your project, unless you want to fundamentally change how a certain plugin works.

Typically the Maven wizards do all you need out of the box and you can parametrize them to suite your project via a using properties.

If further specialization is required you can override how a particular goal is implemented or add a pre/post goal.

e.g. go to any Maven project and type

maven clover

and you'll get a full HTML coverage report of all your JUnit tests!



© Copyright 2007 James Strachan. Click here to send an email to the editor of this weblog.
Last update: 17/4/07; 11:11:34.