What is Gradle

Gradle is an open source build automation tool written in Groovy language. It use a Groovy DSL as build script language. Its programmable and easy to extend. Now Gradle is actively developed and maintained by a professional services company Gradleware.

Gradle is a new generation build tool for modern project management, we have Ant, Ivy, Maven and Gant over the years, and now is Gradle.

Some highlights about Gradle

  • Provide an expressive and readable DSL.
  • The convention over configuration philosophy.
  • Powerful dependency management.
  • Easy to extend.
  • Compatible with Maven or Ant

Gradle is programmable build tool

Which means you can programming your build process. This is unlike what Ant and Maven does, they are not programmable in a sense that you are configuring your build process in these systems. You can see this from the build file they use, Ant and Maven both use XML file, in essence they are just plain text file that contains some key value pairs, you can think them as a json file or a map data structure, they are more data-ish. All you can do with a configuration file is to fill some values to tell the system your intention. Whereas when you look at Gradle's build file, you will find a full blown programming language is working, its just as powerful as any other programming languages, for example, the Java language, probably even more powerful because it support closure and functional programming. Gradle's build file is more code-ish. Some people may argue that using a full fledged programming language just for build is overkill, it will make the learning curve steeper, and almost all existing build tools are not programmable. Believe it or not, build can grow to sufficiently complex that its totally reasonable to use a programmable build tool. Moreover, for a simple build, you can use it just like a configuration file, thanks to the flexible and declarative syntax of Groovy language and closure, a Gradle build script can act like a simple configuration file, without involving any logic code. Actually some of my small projects use a very simple Gradle build file, the only difference between them is the dependency declaration. But when you need to do customized build task, you will have a powerful tool at your disposal.

Gradle is convention based and has the flexibility at the same time

Gradle has the philosophy of build by convention, but its not like Maven's convention, Maven is rigid, Maven make the rules and you must follow, it forces you map any kind of your problems to Maven's convention, even they are not fit quite well, makes you feel boxed in. Gradle's convention is flexible, it has a set of sensible default conventions but allows you to change them and even add your own conventions when needed. Gradle provided convention properties for the default conventions, allows you easily configure them.

Ant, another popular Java build tool gets widely used before Maven , has the full flexibility, but it doesn't has conventions(unopinionated), you and do everything you want in any way, but you are completely on your own, sometimes this kind of flexibility is harmful: its too primitive and trivial. Gradle combines the advantages of Ant and Maven, offering sensible conventions without sacrificing flexibility.

Gradle has a set of sensible and reasonable conventions about: how the source sets are organized, how to compile the source sets, how to package the project to JARs, how to run unit tests, how to deploy code to production environment or even how to control the start and stop of application server like Tomcat. But not in a rigid way, they are all configurable.