Java Reference
In-Depth Information
Automating Dependencies, Compilation, Testing, and
Deployment with Gradle
Problem
You want a build tool that doesn't make you use a lot of XML in your configuration file.
Solution
Use Gradle's simple build file with “strong, yet flexible conventions.”
Discussion
Gradle is the latest in the succession of build tools (
make
,
ant
, and Maven). Gradle bills it-
self as “the enterprise automation tool,” and has integration with the other build tools and
IDEs.
Unlike the other Java-based tools, Gradle doesn't use XML as its scripting language, but
rather a domain-specific language (DSL) based on the JVM-based and Java-based scripting
You can install Gradle by downloading from the
Gradle website
, unpacking the ZIP, and
adding its
bin
subdirectory to your path.
Then you can begin to use Gradle. Assuming you use the “standard” source directory (
src/
main/java
,
src/main/test
) that is shared by Maven and Gradle among other tools, the example
build.gradle
file in
Example 1-2
will build your app and run your unit tests.
Example 1-2. Example build.gradle file
#
Simple Gradle Build
for
for
the Java
-
based DataVis project
apply
plugin:
'java'
#
Set up mappings
for
for
Eclipse project too
apply
plugin:
'eclipse'
#
The version of Java to use
sourceCompatibility
=
1.7
#
The version of my project
version
=
'1.0.3'
#
Configure JAR file packaging
jar
{
manifest
{