Java Reference
In-Depth Information
</target>
</project>
The Gradle build is in the file build.gradle:
ant.importBuild 'build.xml'
task intro(dependsOn: hello) << {
println 'Hello, from Gradle'
}
The
intro
task depends on the
hello
task from the Ant build, which is imported using
the
ant
variable (an instance of
AntBuilder
). Running
gradle intro
executes both
tasks:
:hello
[ant:echo] Hello, from Ant
:intro
Hello, from Gradle
BUILD SUCCESSFUL
The Wrapper task
Finally, a client can execute a Gradle build even if they don't have Gradle installed. Gradle
comes with a special
Wrapper
task, which has a version property:
task wrapper(type: Wrapper) {
gradleVersion = '1.6'
}
RunningthistaskgeneratesscriptsforbothWindowsandUnix,called
gradlew.bat
and
gradlew
, respectively, along with a minimal Gradle JAR distribution. When executed the
wrappers first download and install a local copy of Gradle and then execute the build.
Gradle is a very powerful system, and a thorough investigation is well beyond the scope of
you started.
13
The topic
Gradle in Action
(Manning, 2013) by Benjamin Muschko is both well written and thorough. I highly
recommend it.