Class CompileOptions
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddebugOptions(Action<? super DebugOptions> action) Execute the given action againstgetDebugOptions().voidforkOptions(Action<? super ForkOptions> action) Execute the given action againstgetForkOptions().Returns all compiler arguments, added to thegetCompilerArgs()or thegetCompilerArgumentProviders()property.abstract ConfigurableFileCollectionReturns the classpath to use to load annotation processors.abstract ConfigurableFileCollectionReturns the bootstrap classpath to be used for the compiler process.abstract ListProperty<String> Returns any additional arguments to be passed to the compiler.abstract ListProperty<CommandLineArgumentProvider> Compiler argument providers.getDebug()Tells whether to include debugging information in the generated class files.abstract DebugOptionsReturns options for generating debugging information.Tells whether to log details of usage of deprecated members or classes.Returns the character encoding to be used when reading source files.Returns the extension dirs to be used for the compiler process.Sets whether to fail the build when compilation fails.getFork()Tells whether to run the compiler in its own process.abstract ForkOptionsReturns options for running the compiler in a child process.abstract DirectoryPropertyReturns the directory to place source files generated by annotation processors.abstract DirectoryPropertyIf this option is set to a non-null directory, it will be passed to the Java compiler's `-h` option, prompting it to generate native headers to that directory.informs whether to use incremental compilation feature.Used to enable or disable incremental compilation after a failure.Sets whether to include debugging information in the generated class files.Sets whether to log details of usage of deprecated members or classes.Sets whether to run the compiler in its own process.Sets whether to log warning messages.Set the main class of the Java module, if the module is supposed to be executable.Set the version of the Java module.Tells whether to log the files to be compiled.Configures the Java language version for this compile task (--releasecompiler flag).abstract ConfigurableFileCollectionThe source path to use for the compilation.Tells whether to produce verbose output.Tells whether to log warning messages.
-
Constructor Details
-
CompileOptions
-
-
Method Details
-
getFailOnError
Sets whether to fail the build when compilation fails. Defaults totrue. -
getIsFailOnError
-
getVerbose
Tells whether to produce verbose output. Defaults tofalse. -
getIsVerbose
-
getListFiles
Tells whether to log the files to be compiled. Defaults tofalse. -
getIsListFiles
-
getDeprecation
Tells whether to log details of usage of deprecated members or classes. Defaults tofalse. -
getIsDeprecation
Sets whether to log details of usage of deprecated members or classes. Defaults tofalse. -
getWarnings
Tells whether to log warning messages. The default istrue. -
getIsWarnings
Sets whether to log warning messages. The default istrue. -
getEncoding
Returns the character encoding to be used when reading source files. Defaults tonull, in which case the platform default encoding will be used. -
getDebug
Tells whether to include debugging information in the generated class files. Defaults totrue. SeeDebugOptions.getDebugLevel()for which debugging information will be generated. -
getIsDebug
Sets whether to include debugging information in the generated class files. Defaults totrue. SeeDebugOptions.getDebugLevel()for which debugging information will be generated. -
getDebugOptions
Returns options for generating debugging information. -
debugOptions
Execute the given action againstgetDebugOptions().- Since:
- 8.11
-
getFork
Tells whether to run the compiler in its own process. Note that this does not necessarily mean that a new process will be created for each compile task. Defaults tofalse. -
getIsFork
Sets whether to run the compiler in its own process. Note that this does not necessarily mean that a new process will be created for each compile task. Defaults tofalse. -
getForkOptions
Returns options for running the compiler in a child process. -
forkOptions
Execute the given action againstgetForkOptions().- Since:
- 8.11
-
getBootstrapClasspath
Returns the bootstrap classpath to be used for the compiler process. Defaults to empty.- Since:
- 4.3
-
getExtensionDirs
Returns the extension dirs to be used for the compiler process. Defaults tonull. -
getCompilerArgs
Returns any additional arguments to be passed to the compiler. Defaults to the empty list. Compiler arguments not supported by the DSL can be added here. For example, it is possible to pass the--enable-previewoption that was added in newer Java versions:
Note that ifcompilerArgs.add("--enable-preview")--releaseis added then-targetand-sourceare ignored. -
getAllCompilerArgs
Returns all compiler arguments, added to thegetCompilerArgs()or thegetCompilerArgumentProviders()property.- Since:
- 4.5
-
getCompilerArgumentProviders
Compiler argument providers.- Since:
- 4.5
-
getIncremental
informs whether to use incremental compilation feature. -
getIsIncremental
-
getIncrementalAfterFailure
Used to enable or disable incremental compilation after a failure.By default, incremental compilation after a failure is enabled for Java and Groovy. It has no effect for Scala. It has no effect if incremental compilation is not enabled.
When the Java command line compiler is used, i.e. when a custom java home is passed to forkOptions.javaHome or javac is passed to forkOptions.executable, this optimization is automatically disabled, since the compiler is not invoked via the compiler API.
- Since:
- 7.6
-
getSourcepath
@Optional @IgnoreEmptyDirectories @PathSensitive(RELATIVE) @InputFiles public abstract ConfigurableFileCollection getSourcepath()The source path to use for the compilation.The source path indicates the location of source files that may be compiled if necessary. It is effectively a complement to the class path, where the classes to be compiled against are in source form. It does not indicate the actual primary source being compiled.
The source path feature of the Java compiler is rarely needed for modern builds that use dependency management.
The default value for the source path is
null, which indicates an empty source path. Note that this is different to the default value for the-sourcepathoption forjavac, which is to use the value specified by-classpath. If you wish to use any source path, it must be explicitly set.- Returns:
- the source path
-
getAnnotationProcessorPath
Returns the classpath to use to load annotation processors. This path is also used for annotation processor discovery.- Returns:
- The annotation processor path, or
nullif annotation processing is disabled. - Since:
- 3.4
-
getRelease
Configures the Java language version for this compile task (--releasecompiler flag).If set, it will take precedences over the
AbstractCompile.getSourceCompatibility()andAbstractCompile.getTargetCompatibility()settings.This option is only taken into account by the
JavaCompiletask.- Since:
- 6.6
-
getJavaModuleVersion
Set the version of the Java module.- Since:
- 6.4
-
getJavaModuleMainClass
Set the main class of the Java module, if the module is supposed to be executable.- Since:
- 6.4
-
getGeneratedSourceOutputDirectory
Returns the directory to place source files generated by annotation processors.- Since:
- 6.3
-
getHeaderOutputDirectory
If this option is set to a non-null directory, it will be passed to the Java compiler's `-h` option, prompting it to generate native headers to that directory.- Since:
- 4.10
-