Java Reference
In-Depth Information
}
}
Source sets are collections of source code in a Gradle build. Here, by assigning the sr-
cDirs property of both the src/main/java and src/test/java folders to an empty list, the
Java compiler won't run at all. Instead, the Groovy compiler is used for all classes in the
src directory, which will presumably hold both Java and Groovy classes.
Copying JARs
Another useful tactic is to make a local copy of the dependent libraries. The following task
does that:
task collectJars(type: Copy) {
into "$buildDir/output/lib"
from configurations.testRuntime
}
The collectJars task is a kind of Copy taskā€”one of the built-in task types in Gradle.
Running collectJars copies the JAR files in the runtime classpath into the output/lib
folder in the build directory. Spock uses this task to make a complete distribution.
Inputs and outputs
Another neat capability of Gradle is that it can skip tasks that aren't necessary. It does this
by creating hashes of files and directories and checking whether or not they have changed.
The following listing shows an example taken from the samples [ 11 ] that come with Gradle.
11 See the userguide/tasks/incrementalBuild/inputsAndOutputs directory in the download distribution. Gradle comes
with a huge number of very simple samples like this one.
 
Search WWH ::




Custom Search