If you are working with Java projects, then you are probably using one of the following 3 build tools.
The majority of my experience has been with Ant, which isn’t surprising since its been around the longest. I’ve also used both Gradle and Maven for building Java projects.
Below are some of my thoughts on the benefits\draw-backs of each. For a really detailed comparison of each tool, check out this article!
This is my favorite build tool! It’s probably because I am so familiar with reading Ant XML files. 🙂 I personally like working with XML files. With Ant, there is no preconceived folder\file structure that your project needs to be in. You have the ability to set source location properties in your Ant XML file as needed. There are also many standard “Tasks” that you can use, along with bonus “Contrib” tasks and even “AWS” tasks. For dependency management, you will need to use Apache Ivy in you projects build scripts.
My biggest concern with Ant is the over-all usage of the build tool is going down, which means less contributions from the community.
Ant Example – Compile Java Source (No dependency because its to much to add!!)
<javac srcdir="src" destdir="target"/>
I’m a fan of Maven too! This tool is by far the most popular of the 3. Unlike Ant, Maven can handle both the build and dependency management itself. One of the biggest differences from Ant is the “convention” aspect. With Maven, your project is usually setup following the standard layout. In a lot of ways this is good for new projects. If you are trying to migrate an older project to Maven, this could be bad. My suggestion with Maven is really try to understand the standard project layout before trying to use it to build your projects.
Like Ant, Maven uses XML to define the build process. Maven XML build files are called POM.xml files. These files assume standards and can get extremely large.
Maven Example – Compile with JUnit dependency
This tool is the newest of them all and is gaining traction! The first thing I like about Gradle is the ability to do incremental builds. In some cases, saving 5 minutes of compile time can really add up in terms of $$$. Another bonus is the ability to ingest Ant scripts into the Gradle build process. Finally, like Ant, Gradle does not have to follow a standard project convention, although it does make it a lot easier!
Gradle Example – Compile with JUnit dependency using standard convention
apply plugin: 'java'
I will say that pulling in dependencies is pretty straight forward with Gradle!