Maven versus Ant

Almost every new web project starts with writing the Ant code to build a WAR. This build process is duplicated with some variance on every web application project I've ever worked on that uses Ant.

We lift our noses when we find developers copying and pasting code, yet why do we think it's OK to copy and paste the build process. In my opinion it is not! Using Maven I can start a new project with a nice build process and managed dependencies in no time flat. In Ant, to do the same, I'll copy and paste a build.xml I've used on another project and then begin copying jars into my lib directory. All of a sudden I have tremendous duplication between two projects. What's worse though is that almost every other company developing Java web applications is also writing the build.xml to build their artifacts (jars, wars, and ears) in almost the same way.

I want a build system that manages my dependencies and already knows how to run XDoclet, Unit tests, build javadoc, build a WAR, etc… As long as I put my files where they are expected to be (read sensible defaults) then this build system should be able to build my project almost out of the box. Of course when I need to do custom operations or override a default I need to be able to do that using a property or by breaking out into Ant. These are the reasons why I use Maven. I admit it's not a highly polished and well documented system (which Ant is) but I think Maven is the direction I want to see higher level build systems moving in.

I think Ant and Maven have a very complementary relationship. Maven is a nice high level build system and Ant is a nice low level build system and since Maven let's me use Ant when I want to I'm happy.

This entry was posted in Java. Bookmark the permalink.