15 April 2010
Tags: ant build buildr gant gradle ivy kundo maven
In this post I will not discuss the pros and cons of each and every build tool (mainly because I only worked with Ant and Maven and know and read about the others), but rather start a debate on whether so many tools is required : I’m uncomfortable with the increasing number of build tools available for Java. At the beginning, everything was simple : Ant was here, and did its job. However, while Ant is very good at build customization, it had the cons of its pros: for each project, you had to copy parts of your ant scripts from another project, or create an Ant plugin. However, in every organization, or worse, every developer had its own way of building projects, organizing source code and so you could rapidly come with projects which used the same build tool, but in a totally different manner.
I’m quite happy with Maven 2, which allows us to get reproducible, standardized builds with dependency management. While Maven is not perfect, it has many advantages over Ant, the most important thing to my eyes beeing that the convention based idea forces well structured and understandable code layout. It makes switching from one project to another easy because every project ``look like'' another. You know where to find sources, test sources, resources and so on.
However, Maven 2 is far from perfect, and has many problems :
very poor documentation : there are tons of plugins, but documentation for each plugin is often insufficient.
build descriptors are verbose : that’s XML. XML is verbose.
builds are slow : each build requires parsing the XML files, checking for dependencies, downloading, … and incremental compilation is mostly broken
integrating libraries which do not use Maven, or worse, code compilers/generators which don’t have a Maven plugin is a pain (think of Flex, which lacked a decent plugin until very recently).
Starting from those (and other) problems, people started to create new build tools. To my knowledge, the first one was Ivy, which basically Ant plus dependency management. Great for guys who can’t stand Maven’s well structured (but conservative) build architecture but love the idea of dependency management introduced by Maven. Got to build Flex ? Ok, call the Flex compiler as an Ant task. Done.
I love Groovy. It’s easy to learn if you’re comfortable with Java, and it makes it very easy to write DSLs. The first thing to come was the integration of Ant into Groovy, and the creation of a Groovy DSL for Ant : Gant. It offers you the way to call Ant tasks from Groovy code easily, or, would you like it, build your project with Gant and Groovy code instead of XML files.
A few days ago, the developers announced that Groovy 1.8, the next major version, would use Gradle as a build tool instead of Ant. What it Gradle ? As far as I understand, Gradle can be thought as a Groovy DSL for both Ant and Maven 2, while it does not rely on Maven : it takes the ideas from Maven, combines them with the descriptive tasks from Ant which makes it easy to build customized builds. Why is it so easy ? Well, just because your Gradle builds is actually Groovy code…
That’s the idea. Ok, but I’m aware of different tools which do the same thing :
Buildr, from Apache, defined as A drop-in replacement for Maven 2.0, Buildr uses the same file layout, artifact specifications, local and remote repositories, but uses a dedicated language (not XML, nor Groovy).
Kundo, which just seems to do exactly the same thing as Gradle, but leaks a decent documentation
GMaven, which is a Maven plugin which allows you to compile Groovy code from Maven, compiling and using code from and to Java in Groovy, and allows you to write parts of your build process in Groovy too. This is the tool I’m currently using to build Groovy code from Maven.
Maven 3, yet to be released, which will allow you to abandon your XML files for a Groovy DSL, and use Groovy code in your builds. From what I read, it will likely allow us to to the same thing as Gradle and the previously mentioned tools
This list is based on tools I’m aware of, there must be some other tools available too. But the question is here : do we really need so many tools ?. For me, Ant is required, for its simplicity which allows building projects or libraries without taking care of the Java ecosystem. Maven is required for any larger project, or for OpenSource projects or libraries : thanks to conventional rules and dependency management, it’s quite easy to integrate any library. That makes two. For me, Gradle and other tools are more likely tools that make it easier to build complex projects than revolutionary approches : nothing was impossible to do with Ant or Maven. With Groovy support coming in Maven 3, I’m really wondering if it’s worth learning a new language at the time development teams become comfortable with Maven.
In another software development domain, it makes me think about version control : CVS, Subversion, now Git and Mercurial… And you, what do you think : has the war already begun ?