- Gradle Tutorial
- Gradle – Home
- Gradle – Overview
- Gradle – Installation
- Gradle – Build Script
- Gradle – Tasks
- Gradle – Dependency Management
- Gradle – Plugins
- Gradle – Running a Build
- Gradle – Build a JAVA Project
- Gradle – Build a Groovy Project
- Gradle – Testing
- Gradle – Multi-Project Build
- Gradle – Deployment
- Gradle – Eclipse Integration
- Gradle Useful Resources
- Gradle - Quick Guide
- Gradle - Useful Resources
- Gradle - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Gradle - Overview
In this chapter, we will understand why was there a need to develop Gradle, what are its features and why Groovy programming language was used to develop Gradle.
History of Gradle
Ant and Maven shared considerable success in the JAVA marketplace. Ant was the first build tool released in 2000 and it was developed on procedural programming idea. Later, it was improved with an ability to accept plug-ins and dependency management over the network, with the help on Apache-IVY.
The main drawbacks of Ant include −
- XML is used as a format to write the build scripts.
- Being hierarchical is not good for procedural programming, and
- XML is relatively unmanageable.
Maven was introduced in 2004. It came with lot of improvement than ANT. It was able to change its structure and XML could be used for writing build specifications. Maven relied on the conventions and was able to download the dependencies over the network.
The main benefits of Maven include −
Life cycle of Maven, while following the same life cycle for multiple projects continuously.
Some problems faced by Maven with regards to dependency management include −
It does not handle the conflicts between versions of the same library.
Complex customised build scripts are difficult to write in Maven, as compared to writing the build scripts in ANT.
Finally, Gradle came into picture in 2012 with some efficient features from both the tools.
Features of Gradle
The list of features that Gradle provides.
Declarative builds and build-by-convention
Gradle is available with separate Domain Specific Language (DSL) based on Groovy language.
It provides the declarative language elements. Those elements also provide build-by-convention support for Java, Groovy, OSGI, Web and Scala.
Language for dependency based programming
The declarative language lies on a top of a general purpose task graph, which can be fully supported in the build.
Structure your build
Gradle allows you to apply common design principles to your build. It will give you a perfect structure for build, so that, you can design well-structured and easily maintained, comprehensible build.
By using this API, you can monitor and customise its configuration and execution behavior to the core.
Gradle can easily increase the productivity, from simple and single project builds to huge enterprise multi-project builds.
Gradle supports the multi-project builds and partial builds. If you build a subproject, Gradle takes care of building all the subprojects, that the subproject depends on.
Different ways to manage your builds
Gradle supports different strategies to manage your dependencies.
Gradle is the first build integration tool
Gradle is fully supported for your ANT tasks, Maven and lvy repository infrastructure for publishing and retrieving dependencies. It also provides a converter for turning a Maven pom.xml to Gradle script.
Ease of migration
Gradle can easily adapt to any structure. Therefore, you can always develop your Gradle build in the same branch, where you can build live script.
Gradle Wrapper allows you to execute the Gradle builds on machines, where Gradle is not installed. This is useful for continuous integration of servers.
Free open source
Gradle is an open source project, and licensed under the Apache Software License (ASL).
Gradle's build script are written in Groovy programming language. The whole design of Gradle is oriented towards being used as a language and not as a rigid framework. Groovy allows you to write your own script with some abstractions. The whole Gradle API is fully designed in Groovy language.
Why Groovy for Gradle?
The complete Gradle API is designed using Groovy language. This is an advantage of an internal DSL over XML. Gradle is a general purpose build tool and its main focus is Java projects.
In such projects, the team members will be very familiar with Java and it is better that a build should be as transparent as possible to all the team members.
Languages like Python, Groovy or Ruby are better for build framework. The reason for choosing Groovy is, because, it offers by far the greatest transparency for people using Java. The base syntax of Groovy is same as Java and Groovy provides much more benefits for its users.