What is Gradle?
Gradle is simply a software or toolkit used for building software. These kinds of softwares are also called “build automation software” or “build systems”. Build automation is the process of automating the creation of a software build and the associated processes including: compiling computer source code into binary code, packaging binary code, and running automated tests. Other languages have their own build systems which you might have been familiar with such as make for C/C++, A-A-P, a Python based build tool. Apache Ant for Java etc.
These tools given the rules you specify or teach them, knows how to determine what needs to be created and how to create them. Also note that a build system does not compile, link, package, etc applications directly, what they do is that they direct other systems such as compilers(A compiler is a computer program(s) that transforms source code written in a programming language (the source language) into another computer language (the target language)), Linkers (a linker or link editor is a computer program that takes one or more object files generated by a compiler and combines them into a single executable file, library file, or another object file.) and packages to do the work.
Gradle makes use of a Domain Specific Language(DSL) build on top of Groovy to accomplish tasks specified. Note that a domain-specific language (DSL) is a computer language specialized to a particular application domain eg HTML, CSS for web pages, regular expressions, make, rake, ant and SQL etc. DSL is different from GPL(General Purpose Language) which is use to write applications in a variety of domains examples include PHP, Java, C, C++, Assembly language etc. Martin Fowler is a strong proponent of the idea, he wrote an article on his website.
Android and Gradle
Google developed the Android Plugin for Gradle, this makes it possible for developers to build Android projects with the Gradle Toolkit. Google is also using Gradle and Gradle for Android as the build system behind Android Studio.”We are working on a new build system to replace both the build system inside ADT [Android Development Tools] and Ant,” – the project site from Google states.
The goals of the new build system are:
- Make it easy to reuse code and resources
- Make it easy to create several variants of an application, either for multi-apk distribution or for different flavors of an application
- Make it easy to configure, extend and customize the build process
- Good IDE integration
Moving to Gradle From Eclipse Build System
In the past, we were using Eclipse IDE and Ant to build millions of apps, I don’t why anyone should still be using Eclipse IDE to develop Android apps at all. Ant is not the build tool in the Eclipse IDE but instead a command-line tool. Eclipse IDE has its own build system which is call Eclipse-ADT. These tools still work today, though Ant support is fading fast and is strongly advised to use Android Studio instead.
So why The Switch to Gradle?
- Maintaining two separate build systems (Ant and Eclipse’s native approach) was becoming time-consuming, and would become worse with the advent of Android Studio and yet another build system.
- Getting Ant scripts to do everything that Google needed for builds was getting a bit creaky.
- Gradle is designed to be integrated into IDEs as a library, much more than Ant is.
- Ant has no first-class support for “external artifacts” (e.g., libraries) and dependency management of those libraries.
As we all know, Android Studio uses the Gradle-based build system as its own native approach which is integrated into it for building Android apps. This has a big advantage because it allows Google to focus on only one single build system which is Gradle.
References and further reading
Feedbacks, suggestions, corrections are highly welcome. If you find this helpful, kindly share this.