April 13, 2012

More Maven Goodness


maven logo

This is the last post in a three part series about managing dependencies with Maven.

In two previous articles I've described techniques for managing complex dependencies in software projects. I focused heavily on Maven, a software project management and comprehension tool. I emphasized Maven for two reasons. First, I've used it for years while developing plugins for Atlassian products. The Atlassian plugin SDK is built around Maven and provides a great example of managing a long set of build dependencies. Second, our own Java team at Perforce has had good success with Maven.

These articles spawned a few questions and discussions internally. I thought I'd share some of that, as I found it educational myself. I consider myself proficient but not expert with Maven, and I'm always surprised by how much it can do.

Can Maven be used for non-Java projects?

Yes. There are hundreds of archetypes for Maven, ranging from Java web application development to eBook publishing. There's also a well regarded extension for building C, C++, and Fortran.

Maven handles transitive and circular dependencies

Maven will inspect the POM of a dependency artifact and follow it's dependencies. It will also validate the POM to make sure there are no circular dependencies.

Maven allows for granular or coarse version dependency

You can use Maven version fields to have more flexibility when selecting the version of a dependency. For example, you can just declare the major and minor versions and Maven will automatically use the latest available in that set. If I declare that I want to use log4j 1.2, I'd get the latest in the 1.2 series.

Maven does a lot more than dependency management

  • Maven provides transparency about projects. It can provide reports for unit tests, code coverage, and other key metrics.
  • Maven provides uniformity in the build environment since projects are declared in POM files (no more cryptic scripts).
  • Maven makes continuous integration builds and releases (publishing artifacts to Maven repositories) very easy to automate.

I hope these tidbits come in handy. If you decide to take the Maven plunge, check out P4Maven, which makes Perforce SCM operations available as a standard part of Maven processes.

Read part 1 and part 2 of this series on managing dependencies with Maven.