Maven - Why not?

I guess I still get a little surprised when I see code for a Java project and there's not an automated Maven build. These projects often have an Ant script (many times the default one generated by Netbeans or Eclipse), but seldom a Maven POM file. I wonder why? Especially since Maven is so easy to use and really adds value over a vanilla Ant build. Maven takes an Ant build to a higher level of abstraction to where it's easier to manage and change.

What I think I like most, is the idea of the Maven repository. It's a nice way to store and share application dependencies. In a typical Ant project, dependent JARs will be stored in source control along side the source code (typically in a lib directory). This can make initial checkouts of these projects S-L-O-W. Compounding the problem is when a set of projects use a framework like Spring. Each project will store it's own set of Spring jars with the source, forcing developers to download the same set of jars multiple times for each project.

Maven alleviates this problem somewhat with the notion of a JAR repository (actually a shared directory). For something like Spring, the set of JARs is downloaded once, then shared between all projects needing the jar. The jar repository eliminates the need to store the jars with the source code for the project and makes project downloads quicker while saving disk space.

The list of dependencies each project needs is stored in the projects Maven build file (or POM). The POM lists a projects' JAR dependencies as well as the version of the required JAR. This creates a very detailed snapshot of all the project dependencies for a given release.

Once the project is built for release, Maven allows the opportunity to export the release out to the JAR repository for others to grab. This is a nice way to store and share multiple distributions of your projects - especially internal code libraries which are in turn used by multiple projects.

Maven has it's own plug-in architecture so it's easy to extend. One Maven plug-in I want to mention is Appassember. For projects that include an executable "main" class, Appassembler will copy all the run time libraries to a distribution folder and also create the scripts to start the programs from the command line. This is a great feature and removes some of the tedious tasks in creating releases like these.

I really like Maven and recommend it to everyone.

Comments

Popular posts from this blog

FRail :include

Performance Tuning JCAPS - Part 2

I Believe...