Table of Contents
API Documentation: | CompileOptions |
---|
Main options for Java compilation.
Property | Description |
annotationProcessorGeneratedSourcesDirectory | Incubating The directory to place source files generated by annotation processors. |
annotationProcessorPath | The classpath to use to load annotation processors. This path is also used for annotation processor discovery. |
bootstrapClasspath | The bootstrap classpath to be used for the compiler process. Defaults to |
compilerArgs | 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 |
compilerArgumentProviders | Incubating Compiler argument providers. |
debug | Tells whether to include debugging information in the generated class files. Defaults
to |
debugOptions | Returns options for generating debugging information. |
deprecation | Tells whether to log details of usage of deprecated members or classes. Defaults to |
encoding | The character encoding to be used when reading source files. Defaults to |
extensionDirs | The extension dirs to be used for the compiler process. Defaults to |
failOnError | Tells whether to fail the build when compilation fails. Defaults to |
fork | 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 to |
forkOptions | Returns options for running the compiler in a child process. |
headerOutputDirectory | Incubating 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. |
incremental | informs whether to use incremental compilation feature. See |
listFiles | Tells whether to log the files to be compiled. Defaults to |
sourcepath | The source path to use for the compilation. |
verbose | Tells whether to produce verbose output. Defaults to |
warnings | Tells whether to log warning messages. The default is |
Method | Description |
debug(debugArgs) | Convenience method to set |
fork(forkArgs) | Convenience method to set |
File
annotationProcessorGeneratedSourcesDirectory
Note: This property is incubating and may change in a future version of Gradle.
The directory to place source files generated by annotation processors.
- Default with
java
plugin: ${project.buildDir}
/generated/sources/annotationProcessor/${sourceDirectorySet.name}
/${sourceSet.name}
FileCollection
annotationProcessorPath
The classpath to use to load annotation processors. This path is also used for annotation processor discovery.
- Default with
java
plugin: sourceSet
.annotationProcessorPath
FileCollection
bootstrapClasspath
The bootstrap classpath to be used for the compiler process. Defaults to null
.
- Default with
java
plugin: null
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 --release
option of JDK 9:
compilerArgs.addAll(['--release', '7'])
Note that if --release
is added then -target
and -source
are ignored.
- Default with
java
plugin: []
List
<CommandLineArgumentProvider
>
compilerArgumentProviders
(read-only)
List
<CommandLineArgumentProvider
>Note: This property is incubating and may change in a future version of Gradle.
Compiler argument providers.
- Default with
java
plugin: []
Tells whether to include debugging information in the generated class files. Defaults
to true
. See DebugOptions.getDebugLevel()
for which debugging information will be generated.
- Default with
java
plugin: true
DebugOptions
debugOptions
Returns options for generating debugging information.
Tells whether to log details of usage of deprecated members or classes. Defaults to false
.
- Default with
java
plugin: false
String
encoding
The character encoding to be used when reading source files. Defaults to null
, in which
case the platform default encoding will be used.
- Default with
java
plugin: null
String
extensionDirs
The extension dirs to be used for the compiler process. Defaults to null
.
- Default with
java
plugin: null
Tells whether to fail the build when compilation fails. Defaults to true
.
- Default with
java
plugin: true
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 to false
.
- Default with
java
plugin: false
ForkOptions
forkOptions
Returns options for running the compiler in a child process.
DirectoryProperty
headerOutputDirectory
Note: This property is incubating and may change in a future version of Gradle.
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.
- Default with
java
plugin: null
informs whether to use incremental compilation feature. See CompileOptions.setIncremental(boolean)
- Default with
java
plugin: true
Tells whether to log the files to be compiled. Defaults to false
.
- Default with
java
plugin: false
FileCollection
sourcepath
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 -sourcepath
option for javac
, which is to use the value specified by -classpath
.
If you wish to use any source path, it must be explicitly set.
- Default with
java
plugin: null
Tells whether to produce verbose output. Defaults to false
.
- Default with
java
plugin: false
CompileOptions
debug
(Map
<String
, Object
>
debugArgs)
Map
<String
, Object
>Convenience method to set DebugOptions
with named parameter syntax.
Calling this method will set debug
to true
.
CompileOptions
fork
(Map
<String
, Object
>
forkArgs)
Map
<String
, Object
>Convenience method to set ForkOptions
with named parameter syntax.
Calling this method will set fork
to true
.