Opinion: Gradle > Maven

We're all about the individual developer, not our employers.

Opinion: Gradle > Maven

One of the great debates in the Java Virtual Machine world is the superiority of Gradle vs Maven. I have used both Maven and Gradle for a combined total of 12 years. As an experienced user of both tools, I understand the debate and have made my own conclusions. While Maven does have some advantages, my preference is for Gradle and my reasons are as follows:

  1. Maven is a markup language, not a programming language. Any project that becomes moderately large and complex in size needs a build tool that can accommodate that. The consequence for Maven being a markup language is that at scale it becomes a huge jumbled mess of maven profiles invoked by an XML document that is not comprehensible. [As Opposed to Gradle…]
  2. Maven is not very portable. Maven has to be installed on every agent that needs to run your maven pom.xml. Gradle’s wrapper solves that problem. I can run as many different versions of Gradle via the wrapper as I want on a CI machine, or branch of my code, etc. and not have to worry about what is installed on an individual machine. In my opinion, this is HUGE.
  3. Gradle knows what tasks are up-to-date and which aren’t. Gradle won’t run tasks that are already up-to-date and only incrementally runs those which the inputs and/or outputs of tasks are not. For large builds, this is a significant time-saver.
  4. Gradle has a build cache that can reuse the outputs of any other build with the same inputs.
  5. Gradle also leverages a Gradle daemon, which keeps the Gradle executable running when a build isn’t cutting out the overhead of starting another Gradle executable.
  6. Gradle’s segregation of tests allows the segregation of micro tests vs. larger integration tests and e2e tests, performance tests, etc.
  7. Gradle has the ability to control the order of execution of tasks which I find myself leveraging frequently.

The only advantage of Maven is Maven’s plugin authoring. For me, the Gradle plugin API was a bit awkward at the time. It may very well have been being new to Gradle, it wasn’t very straightforward. But I haven’t had any real need to create a plugin, someone has usually beat me to it and it is already available.

Here are some extra things that are written by the Gradle folks, so YMMV:https://gradle.org/maven-vs-gradle/

Mike Smithson

Mike has been portraying a software engineer for over 20 years and finding out as every day passes by, what a beginner he is. Mike discovered XP programming 12 years ago and has been hooked ever since. His passions include anything that makes the daily grind of creating and delivering value suck less than the day before. He currently resides in Farmington, Michigan and works for one of the major employers in the Southeast Michigan area. 

Leave a Reply