java.io.Serializable
public class GroovyCompileOptions extends AbstractOptions
Constructor | Description |
---|---|
GroovyCompileOptions() |
Modifier and Type | Method | Description |
---|---|---|
GroovyCompileOptions |
fork(java.util.Map<java.lang.String,java.lang.Object> forkArgs) |
Convenience method to set
GroovyForkOptions with named parameter syntax. |
java.io.File |
getConfigurationScript() |
A Groovy script file that configures the compiler, allowing extensive control over how the code is compiled.
|
SetProperty<java.lang.String> |
getDisabledGlobalASTTransformations() |
Returns the set of global AST transformations which should not be loaded into the Groovy compiler.
|
java.lang.String |
getEncoding() |
Tells the source encoding.
|
java.util.List<java.lang.String> |
getFileExtensions() |
Returns the list of acceptable source file extensions.
|
GroovyForkOptions |
getForkOptions() |
Returns options for running the Groovy compiler in a separate process.
|
protected ObjectFactory |
getObjectFactory() |
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getOptimizationOptions() |
Returns optimization options for the Groovy compiler.
|
java.io.File |
getStubDir() |
Returns the directory where Java stubs for Groovy classes will be stored during Java/Groovy joint
compilation.
|
boolean |
isFailOnError() |
Tells whether the compilation task should fail if compile errors occurred.
|
boolean |
isFork() |
Tells whether to run the Groovy compiler in a separate process.
|
boolean |
isJavaAnnotationProcessing() |
Whether the Groovy code should be subject to Java annotation processing.
|
boolean |
isKeepStubs() |
Tells whether Java stubs for Groovy classes generated during Java/Groovy joint compilation
should be kept after compilation has completed.
|
boolean |
isListFiles() |
Tells whether to print which source files are to be compiled.
|
boolean |
isParameters() |
Whether the Groovy compiler generate metadata for reflection on method parameter names on JDK 8 and above.
|
boolean |
isVerbose() |
Tells whether to turn on verbose output.
|
void |
setConfigurationScript(java.io.File configurationFile) |
Sets the path to the groovy configuration file.
|
void |
setEncoding(java.lang.String encoding) |
Sets the source encoding.
|
void |
setFailOnError(boolean failOnError) |
Sets whether the compilation task should fail if compile errors occurred.
|
void |
setFileExtensions(java.util.List<java.lang.String> fileExtensions) |
Sets the list of acceptable source file extensions.
|
void |
setFork(boolean fork) |
Sets whether to run the Groovy compiler in a separate process.
|
void |
setForkOptions(GroovyForkOptions forkOptions) |
Sets options for running the Groovy compiler in a separate process.
|
void |
setJavaAnnotationProcessing(boolean javaAnnotationProcessing) |
Sets whether Java annotation processors should process annotations on stubs.
|
void |
setKeepStubs(boolean keepStubs) |
Sets whether Java stubs for Groovy classes generated during Java/Groovy joint compilation
should be kept after compilation has completed.
|
void |
setListFiles(boolean listFiles) |
Sets whether to print which source files are to be compiled.
|
void |
setOptimizationOptions(java.util.Map<java.lang.String,java.lang.Boolean> optimizationOptions) |
Sets optimization options for the Groovy compiler.
|
void |
setParameters(boolean parameters) |
Sets whether metadata for reflection on method parameter names should be generated.
|
void |
setStubDir(java.io.File stubDir) |
Sets the directory where Java stubs for Groovy classes will be stored during Java/Groovy joint
compilation.
|
void |
setVerbose(boolean verbose) |
Sets whether to turn on verbose output.
|
define
@Inject protected ObjectFactory getObjectFactory()
@Input public boolean isFailOnError()
true
.public void setFailOnError(boolean failOnError)
true
.@Console public boolean isVerbose()
false
.public void setVerbose(boolean verbose)
false
.@Console public boolean isListFiles()
false
.public void setListFiles(boolean listFiles)
false
.@Input public java.lang.String getEncoding()
UTF-8
.public void setEncoding(java.lang.String encoding)
UTF-8
.@Input public boolean isFork()
true
.public void setFork(boolean fork)
true
.@Nullable @Optional @PathSensitive(NONE) @InputFile public java.io.File getConfigurationScript()
The script is executed as Groovy code, with the following context:
configuration
variable.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.
public void setConfigurationScript(@Nullable java.io.File configurationFile)
getConfigurationScript()
@Input public boolean isJavaAnnotationProcessing()
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.
public void setJavaAnnotationProcessing(boolean javaAnnotationProcessing)
false
.@Input public boolean isParameters()
public void setParameters(boolean parameters)
false
public GroovyForkOptions getForkOptions()
fork
is set to true
.public void setForkOptions(GroovyForkOptions forkOptions)
fork
is set to true
.@Nullable @Optional @Input public java.util.Map<java.lang.String,java.lang.Boolean> getOptimizationOptions()
true
and false
.
Only takes effect when compiling against Groovy 1.8 or higher.
Known options are:
public void setOptimizationOptions(@Nullable java.util.Map<java.lang.String,java.lang.Boolean> optimizationOptions)
true
and false
.
Only takes effect when compiling against Groovy 1.8 or higher.@Incubating @Input public SetProperty<java.lang.String> getDisabledGlobalASTTransformations()
@Internal public java.io.File getStubDir()
null
, in which case a temporary directory will be used.public void setStubDir(java.io.File stubDir)
null
, in which case a temporary directory will be used.@Input public java.util.List<java.lang.String> getFileExtensions()
ImmutableList.of("java", "groovy")
.public void setFileExtensions(java.util.List<java.lang.String> fileExtensions)
ImmutableList.of("java", "groovy")
.@Input public boolean isKeepStubs()
false
.public void setKeepStubs(boolean keepStubs)
false
.public GroovyCompileOptions fork(java.util.Map<java.lang.String,java.lang.Object> forkArgs)
GroovyForkOptions
with named parameter syntax.
Calling this method will set fork
to true
.