|Developer(s)||Hans Dockter, Adam Murdoch, Szczepan Faber, Peter Niederwieser, Luke Daley, Rene Gröschke, Daz DeBoer, Steve Appling|
|Stable release||2.0 / 1 July 2014|
|Written in||Java, Groovy|
|License||Apache License 2.0|
Gradle is a project automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the more traditional XML form of declaring the project configuration.
Unlike Apache Maven, which defines lifecycles, and Apache Ant, where targets are invoked based upon a depends-on partial ordering, Gradle uses a directed acyclic graph ("DAG") to determine the order in which tasks can be run.
Gradle was designed for multi-project builds which can grow to be quite large, and supports incremental builds by intelligently determining which parts of the build tree are up-to-date, so that any task dependent upon those parts will not need to be re-executed.
Example Java project
Consider the case where the Maven directory structure is used for Java sources and resources. These directories are: src/main/java, src/main/resources, src/test/java and src/test/resources.
apply plugin: 'java'
Running gradle build will result in
> gradle build:compileJava :processResources :classes :jar :assemble :compileTestJava :processTestResources :testClasses :test :check :build BUILD SUCCESSFUL
The Java plugin emulates many of the expected Maven lifecycles as tasks in the directed acyclic graph of dependencies for the inputs and outputs of each task. For this simple case, the build task depends upon the outputs of the check and assemble tasks. Likewise, check depends upon test, and assemble depends upon jar.
For projects that do not follow the Maven conventions, Gradle allows the directory structure to be configured. The following example would support a project that contains source files in src/java rather than the src/main/java convention enforced by Maven.
apply plugin: 'java' sourceSets.main.java.srcDirs = ['src/java']
Example Ant migration
Gradle has a very tight integration with Ant, and even treats Ant build files as scripts that could be directly imported while building. The below example shows a simplistic Ant target being incorporated as a Gradle task.
<project> <target name="ant.target"> <echo message="Running ant.target!"/> </target> </project>
Running gradle ant.target will result in
> gradle ant.target:ant.target [ant:echo] Running ant.target! BUILD SUCCESSFUL
Past versions are available from Gradle's download page.
- Berglund, Tim; McCullough, Matthew (July 2011). Building and Testing with Gradle. Foreword by Hans Dockter (First ed.). O'Reilly Media. p. 116. ISBN 978-1-4493-0463-8.
- Ikkink, Hubert (November 2012). Gradle Effective Implementation Guide (First ed.). Packt Publishing. p. 382. ISBN 978-1849518109.
- Berglund, Tim; McCullough, Matthew (May 2013 est.). Gradle DSLs (First ed.). O'Reilly Media. pp. 50 est. ISBN 978-1-4493-0467-6.
- Muschko, Benjamin (Fall 2013). Gradle In Action (First ed.). Manning Publications. p. 390. ISBN 9781617291302.
- gradleware.com for commercial Gradle support
- Gradle Summit 2013, June 13-14th, Santa Clara, CA
- Overview of Gradle
- Gradle presentation at San Francisco JUG by Gradle founder Hans Dockter
- Breaking Open: Gradle - An interview about Gradle and Gradleware, its history, motivation and challenges. With Gradle founder Hans Dockter and Aleksandar Gargenta.
- Standard plugins that ship with Gradle
- Gradle: Java Quickstart Guide
- Gradle: Groovy Quickstart Guide
- Examples of Ant usage within Gradle
- Gradle Forums
- Gradle Presentation
- Getting Started by schuchert
- Prototypes for gradle project