Skip to content

Why I Use Maven

2009 February 12
by Nayan Hajratwala

I was asked recently why I like Maven so much. Here’s why:

  • The most basic project structure will compile code, run all your unit tests, and build a jar file:
    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.chikli.testprojecct</groupId>
      <artifactId>testproject</artifactId>
      <version>1</version>
    </project>
  • Due to the standardization, and logical defaults/conventions, I can open up any project that uses Maven for it’s build system and immediately understand the build process and the generated artifacts. This is in stark contrast to ant buildfiles which are custom from project to project.
  • Since all needed artifacts (jars) are versioned and live in a Maven Repository, I don’t have to include the actual jar files for third party libraries within my project structure.
  • I can run a single command and immediately see if any of the libraries that my project uses has released any updates (i.e. new versions of spring, hibernate, commons-*, etc):
    • mvn versions:display-dependency-updates
  • I can change the version of a library that my project uses simply by typing in the version I want.
  • Documentation – this has traditionally been horrible for Maven, but Sonatype has recently created an excellent free online book that covers all you need to know about using Maven.

I’m pretty sure there’s more I like about Maven, but these are the ones that came to me right away.