In Support Of Maven

In the last few days there has been an article completely bashing Maven on hacker news. I found this a little aggravating. Much of the article spent time complaining about how the files are structured, and how much effort it takes to maintain a Maven file. Also, the article complained about the plug-in structure.

To some extent I can agree with the original author. The plug-in system makes Maven a little difficult to learn and get completely right. On the other hand, the plug-in system makes it easy to deliver a single meta-build system that can easily adapt to what you need it to do. Building a Java web app? It has a plug-in to build and package it for you.

My main beef with the article is that it completely ignores why we got Maven in the first place. It builds, packages, and manages your dependencies better than ANT does. Before, you had to manually acquire, and grab your dependencies. If you had ANT or make, then you had to include the declarations for the dependencies in the build file, and put the dependency in your project. This is a pain for those that are using source control, and for setting up new developer machines. However, with Maven, just declare the dependency and the scope in the build file and you’re done. If you’re using an IDE it’ll bring in the references and may be able to pull the Javadoc if it’s available. Additionally, any new upgrades to the dependencies could be added just by changing the version number. Imagine doing that without a Maven like build system. Maven can even go the extra mile and create a redistributable package [this is a little tricky, but you can do it], deploy your new package to a repository, check in your code for you, or even deploy it to a webserver. For example, if you have a web service and don’t have Tomcat7 downloaded, run it with an embedded instance with mvn tomcat7:run . You’re done, Maven grabs Tomcat7, its dependences and tries to deploy your webapp to the new instance of Tomcat7. No installation of the server required.

In closing, Maven is a build tool. Unless you’re making project structure changes you shouldn’t be messing about with the way it builds things.

  • http://twitter.com/josefbetancourt josef betancourt

    Ant now has Ivy, and then there is Gradle.  So, other systems got the message, and Maven’s features are being duplicated.  Is Maven still the best?  Depends on what you need.  If you can abide by the default Maven “conventions” your set, if not, …