Advantages of Gradle compared to Ant and Maven
Gradle is new and compatible with old build tool
Gradle is much newer java build tool, Ant first released in 2000, Maven 2004, Gradle was released in 2012. And it compatible with Ant and Maven, you can use Maven repository in Gradle, convert Maven POM to Gardle build file easily.
It has all the advantages that Maven has, for example convention over configuration, but also let you do things you can never do in Maven.
Gradle use task as basic unit of building, just like Ant task, but with more flexibility. You can use all Ant task in Gradle, but in syntax of Groovy.
Gradle is programmable
The Gradle configuration file itself is Groovy script, its a true programming language, both Ant and Maven are just XML configuration file, they are just data, but Gradle is data and code at the same time. Not only XML is not programmable , it also annoying to be text format, no wonder so many people hate XML.
A Gradle build script has two phrases: evaluation and execution. Evaluation phrase will run the script code, execution phrase will run tasks built by the evaluation phrase.
Gradle build file is smaller
In Maven, declare one dependency needs 5 lines for example
<dependency> <groupdId>junit</groupdId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency>
It also contains XML tag noises. Gradle only needs one line
Isn't that easier to write , read or understand?
Gradle has an awesome plugin system
Thanks to the programmability of the Groovy DSL, its easy to create plugin for Gradle, there are plenty of Gradle plugin you can use to extend your build cycle.
Gradle supports multi-project
When your project gets bigger and more complex, you need to split the project to sub project, and Gradle has great support for this, allows you organize your code to sub modules and define the dependencies between them.