Java Reference
In-Depth Information
The Spock framework (discussed in chapter 6 ) takes the former approach. Spock versions
are in the form 0.7-groovy-2.0, meaning Spock version 0.7 compiled with Groovy version
2.0.
The Grails and Gradle projects take the other approach. Grails 1.3.9, for example, includes
a copy of Groovy 1.7.8, Grails 2.0.3 includes Groovy 1.8.6, and Grails 2.2.1 includes
Groovy 2.0.8. To see the Groovy version included in your Gradle distribution, run the
gradle -v command.
For Grails, the bundled Groovy version locks you into that version for the entire applica-
tion. For Gradle, however, the bundled Groovy version is used only to execute the build
script itself. You're free to use any version of Groovy in your own projects, and Gradle will
correctly build them.
When you run the gradle -v command, in addition to showing the Gradle and Groovy
versions, Gradle also reports the included versions of Ant and Ivy, as well as the JVM and
OS.
Gradle builds range from extremely simple to quite powerful. I'll start with the simplest
possible example and build from there.
5.6.1. Basic Gradle builds
Gradle is a plugin-based architecture. Most Gradle tutorials start by defining what a task is
and showing how to call one. Rather than do that here, let me instead show you a minimal
build file and go from there.
Here's the smallest possible Gradle build for a Java project, in a file called build.gradle:
apply plugin:'java'
The apply syntax indicates that the build is using the Java plugin. When you run the
build command using this file, Gradle executes tasks in several stages, as shown:
Search WWH ::




Custom Search