dagblog.
← Archive

Maven Is Pretty Good


Last week, a debate went around the Java community about whether Maven was the right tool. Reading the responses, I got the impression everyone suddenly wanted to take a kick at Maven. We've been using it for a while, so I can judge it from experience. The most common complaints concern the following.

  • Bad metadata in the central repository
  • An overly verbose POM as the source of metadata
  • Transitive dependencies
  • The way JAR dependencies and project dependencies are treated
  • Limited IDE support
  • Poorly maintained plugins

Bad metadata in the central repository, combined with transitive dependencies, causes a lot of trouble and puts many developers off Maven. See Dependencies in Maven for a way to deal with it. I find transitive dependencies very useful, though I understand why some people would rather do without them.

Responsibility for bad metadata in the central repository lies with the people maintaining it. The same goes for plugins. Maven's creators can guarantee that the core plugins work. Which plugins and versions you choose is up to you. As with many of the other supposed drawbacks, it's more a matter of setting some ground rules, or establishing a working culture, for using Maven.

The POM as a source of metadata. Honestly, I don't quite get this complaint. What would be a better way to describe it, something less structured? I do think the distinction between a JAR dependency and a project dependency is one of Maven's most contentious features. The problem is that it behaves differently depending on the context. A build run at the root of a multi-project build behaves differently from one run inside a subproject. Still, it's hardly rocket science, and it behaves consistently once you know which context you're in.

Limited IDE support. There are two ways an IDE can support Maven. It can generate project files or integrate Maven directly into the development environment. As an Eclipse user, I'm entirely happy with the first option. I may be biased because I don't build UIs, so I don't need hot deployment or the other things that complicate life for many developers and give tool designers room to help.

After several years with Ant and several months with Maven, I wouldn't go back to Ant for anything. The oft-repeated distinction is that with Ant you program the build, while with Maven you describe the project, at least most of the time.

I also appreciate knowing that whichever component of our system I open, mvn test will run the tests and mvn compile will compile the code. Every component works the same way from a project management perspective. There are plenty of other benefits, including centralized dependencies and settings, a standard project structure, and useful reports for things like code coverage and static analysis. Of course, I could have all of that in Ant, too, but I'd spend about half as much time again setting it up, and within a few months it would all be unmaintainable.

As the saying goes, if you want to beat a dog, you'll always find a stick. The same goes for Maven. It has its drawbacks, like any other tool, but we don't have anything better yet. So my verdict is that Maven is pretty good.

Medium version

Related articles

Related CZ Podcast episodes