Gradle is written in Groovy and offers you to write your build scripts in Groovy. But this is an internal aspect of Gradle which is strictly separated from building Groovy projects. You are free to choose the Groovy version your project should be build with. This Groovy version is not just used for compiling your code and running your tests. The groovyc compiler and the the groovydoc tool are also taken from the Groovy version you provide. As usual, with freedom comes responsibility ;). You are not just free to choose a Groovy version, you have to provide one. Gradle expects that the groovy libraries are assigned to the groovy dependency configuration. Here are some examples how this works (the notation depends on your resolvers):
|
|
|
|
|
|
All the Groovy source directories can contain Groovy and Java code. The Java source directories may only contain Java source code (and can of course be empty)2
The GroovyCompile task has two instances, compile and testCompile. The task type extends the Compile task (see section 10.1)
| Additional Convention to Property Mapping
| ||
| Task Instance | Task Property | Convention Property |
| compile | groovySourceDirs | groovySrcDirs |
| testCompile | groovySourceDirs | groovyTestSrcDirs |
Have a look at org.gradle.api.tasks.compile.GroovyCompile to learn about the details. The compile task delegates to the Ant Groovyc task to do the compile. Via the compile task you can set most of the properties of Ants Groovyc task.
/
In contrast to the Java plugin the fork mode is set to once by default, because of the significant startup time of Groovy. The Java plugin uses per test as fork mode (see section 9.6).