Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why should I use Gradle instead of Ant?

 
Rogerio Kioshi
Ranch Hand
Posts: 690
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Hubert Klein Ikkink
author
Greenhorn
Posts: 13
IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rogerio,

Gradle is a build language, a Groovy-based DSL to define your builds. This means you don't have to develop your builds in XML, but you can use a proper language. You can add methods, refactor and create beautiful maintainable build files.
I think a big advantage compared to Ant is the support of plugins in Gradle. A plugin contains build configuration and custom tasks in a single package. You don't have to redefine a Java compiler task for each project, but you can re-use the compiler task from the Java plugin for example. This way it is much easier to re-use tasks across projects.

Ant is great because of the flexibility, we are not bound to a rigid predefined way of working. Gradle gives a choice. We can use the convention-over-configuration feature and really fast create a build for our project, but if the project is different (for example legacy source code directory structure) we can also adjust it easily.

Also Gradle can use existing Ant tasks, custom tasks and build files: http://www.gradle.org/docs/current/userguide/ant.html. The transition is not that hard.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic