Table of Contents
API Documentation: | GroovyCompileOptions |
---|
Compilation options to be passed to the Groovy compiler.
Property | Description |
configurationScript | A Groovy script file that configures the compiler, allowing extensive control over how the code is compiled. |
disabledGlobalASTTransformations | The set of global AST transformations which should not be loaded into the Groovy compiler. |
encoding | Tells the source encoding. Defaults to |
failOnError | Tells whether the compilation task should fail if compile errors occurred. Defaults to |
fileExtensions | The list of acceptable source file extensions. Only takes effect when compiling against
Groovy 1.7 or higher. Defaults to |
fork | Tells whether to run the Groovy compiler in a separate process. Defaults to |
forkOptions | Returns options for running the Groovy compiler in a separate process. These options only take effect
if |
javaAnnotationProcessing | Whether the Groovy code should be subject to Java annotation processing. |
keepStubs | Tells whether Java stubs for Groovy classes generated during Java/Groovy joint compilation
should be kept after compilation has completed. Useful for joint compilation debugging purposes.
Defaults to |
listFiles | Tells whether to print which source files are to be compiled. Defaults to |
optimizationOptions | Returns optimization options for the Groovy compiler. Allowed values for an option are |
parameters | Whether the Groovy compiler generate metadata for reflection on method parameter names on JDK 8 and above. |
stubDir | The directory where Java stubs for Groovy classes will be stored during Java/Groovy joint
compilation. Defaults to |
verbose | Tells whether to turn on verbose output. Defaults to |
Method | Description |
fork(forkArgs) | Deprecated Convenience method to set |
File
configurationScript
A Groovy script file that configures the compiler, allowing extensive control over how the code is compiled.
The script is executed as Groovy code, with the following context:
- The instance of CompilerConfiguration available as the
configuration
variable. - All static members of CompilerCustomizationBuilder pre imported.
This facilitates the following pattern:
withConfig(configuration) {
// use compiler configuration DSL here
}
For example, to activate type checking for all Groovy classes…
import groovy.transform.TypeChecked
withConfig(configuration) {
ast(TypeChecked)
}
Please see the Groovy compiler customization builder documentation for more information about the compiler configuration DSL.
This feature is only available if compiling with Groovy 2.1 or later.
- Default:
null
SetProperty
<String
>
disabledGlobalASTTransformations
SetProperty
<String
>The set of global AST transformations which should not be loaded into the Groovy compiler.
- Default:
["groovy.grape.GrabAnnotationTransformation"]
Tells whether the compilation task should fail if compile errors occurred. Defaults to true
.
- Default:
true
The list of acceptable source file extensions. Only takes effect when compiling against
Groovy 1.7 or higher. Defaults to ImmutableList.of("java", "groovy")
.
- Default:
["java", "groovy"]
Tells whether to run the Groovy compiler in a separate process. Defaults to true
.
- Default:
true
GroovyForkOptions
forkOptions
Returns options for running the Groovy compiler in a separate process. These options only take effect
if fork
is set to true
.
Whether the Groovy code should be subject to Java annotation processing.
Annotation processing of Groovy code works by having annotation processors visit the Java stubs generated by the Groovy compiler in order to support joint compilation of Groovy and Java source.
When set to true
, stubs will be unconditionally generated for all Groovy sources, and Java annotations processors will be executed on those stubs.
When this option is set to false
(the default), Groovy code will not be subject to annotation processing, but any joint compiled Java code will be.
If the compiler argument "-proc:none"
was specified as part of the Java compile options, the value of this flag will be ignored.
No annotation processing will be performed regardless, on Java or Groovy source.
- Default:
false
Tells whether Java stubs for Groovy classes generated during Java/Groovy joint compilation
should be kept after compilation has completed. Useful for joint compilation debugging purposes.
Defaults to false
.
- Default:
false
Tells whether to print which source files are to be compiled. Defaults to false
.
- Default:
false
Returns optimization options for the Groovy compiler. Allowed values for an option are true
and false
.
Only takes effect when compiling against Groovy 1.8 or higher.
Known options are:
- indy
- Use the invokedynamic bytecode instruction. Requires JDK7 or higher and Groovy 2.0 or higher. Disabled by default.
- int
- Optimize operations on primitive types (e.g. integers). Enabled by default.
- all
- Enable or disable all optimizations. Note that some optimizations might be mutually exclusive.
- Default:
[:]
Whether the Groovy compiler generate metadata for reflection on method parameter names on JDK 8 and above.
- Default:
false
File
stubDir
The directory where Java stubs for Groovy classes will be stored during Java/Groovy joint
compilation. Defaults to null
, in which case a temporary directory will be used.
- Default:
null
GroovyCompileOptions
fork
(Map
<String
, Object
>
forkArgs)
Map
<String
, Object
>Note: This method is deprecated and will be removed in the next major version of Gradle.
Convenience method to set GroovyForkOptions
with named parameter syntax.
Calling this method will set fork
to true
.