|Developer(s)||Hans Dockter, Adam Murdoch, Szczepan Faber, Peter Niederwieser, Luke Daley, Rene Gröschke, Daz DeBoer, Steve Appling|
4.5.1 / February 5, 2018
|Written in||Java, Groovy|
|License||Apache License 2.0|
Gradle is an open-source build automation system that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the XML form used by Apache Maven for declaring the project configuration. 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. It supports incremental builds by intelligently determining which parts of the build tree are up to date; any task dependent on those parts does not need to be re-executed.
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']
Gradle has a very tight integration with Ant, and even treats Ant build files as scripts that could be directly imported while building. The example below 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
Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.