Gradle

Gradle
Developer(s) Hans Dockter, Adam Murdoch, Szczepan Faber, Peter Niederwieser, Luke Daley, Rene Gröschke, Daz DeBoer, Steve Appling
Initial release 2007 (2007)
Stable release
3.1[1] / September 19, 2016 (2016-09-19)
Repository github.com/gradle/gradle
Development status Active
Written in Java, Groovy
Operating system Cross-platform
Type Build Tool
License Apache License 2.0
Website www.gradle.org

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 of declaring the project configuration.[2] 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.

The initial plugins are primarily focused around Java,[3] Groovy and Scala development and deployment, but more languages and project workflows are on the roadmap.

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.

build.gradle

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.

build.gradle

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 example below shows a simplistic Ant target being incorporated as a Gradle task.

build.xml

<project>
  <target name="ant.target">
    <echo message="Running ant.target!"/>
  </target>
</project>

build.gradle

ant.importBuild 'build.xml'

Running gradle ant.target will result in

> gradle ant.target
:ant.target
[ant:echo] Running ant.target!

BUILD SUCCESSFUL

See also

References

  1. "Download Gradle l Open Source Enterprise Build Automation". Gradle.org. 2016-09-19. Retrieved 2016-09-19.
  2. "Getting Started With Gradle". Petri Kainulainen. Retrieved 26 March 2016.
  3. "Getting Started · Building Java Projects with Gradle". Retrieved 26 March 2016.

Bibliography

This article is issued from Wikipedia - version of the 11/16/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.