Package org.gradle.api.tasks.compile
Class CompileOptions
java.lang.Object
org.gradle.api.tasks.compile.AbstractOptions
org.gradle.api.tasks.compile.CompileOptions
- All Implemented Interfaces:
Serializable
Main options for Java compilation.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvenience method to setDebugOptions
with named parameter syntax.protected boolean
excludeFromAntProperties
(String fieldName) Convenience method to setForkOptions
with named parameter syntax.Returns the directory to place source files generated by annotation compilers.Returns the classpath to use to load annotation processors.protected String
getAntPropertyName
(String fieldName) protected Object
getAntPropertyValue
(String fieldName, Object value) Deprecated.Returns the bootstrap classpath to be used for the compiler process.Returns any additional arguments to be passed to the compiler.Returns options for generating debugging information.Returns the character encoding to be used when reading source files.Returns the extension dirs to be used for the compiler process.Returns options for running the compiler in a child process.The source path to use for the compilation.boolean
isDebug()
Tells whether to include debugging information in the generated class files.boolean
Tells whether to log details of usage of deprecated members or classes.boolean
Tells whether to fail the build when compilation fails.boolean
isFork()
Tells whether to run the compiler in its own process.boolean
informs whether to use incremental compilation feature.boolean
Tells whether to log the files to be compiled.boolean
Tells whether to produce verbose output.boolean
Tells whether to log warning messages.Internal method.void
Sets the directory to place source files generated by annotation compilers.void
Sets the directory to place source files generated by annotation compilers.void
setAnnotationProcessorPath
(FileCollection annotationProcessorPath) Set the classpath to use to load annotation processors.void
setBootClasspath
(String bootClasspath) Deprecated.UsesetBootstrapClasspath(FileCollection)
instead.void
setBootstrapClasspath
(FileCollection bootstrapClasspath) Sets the bootstrap classpath to be used for the compiler process.void
setCompilerArgs
(List<String> compilerArgs) Sets any additional arguments to be passed to the compiler.void
setDebug
(boolean debug) Sets whether to include debugging information in the generated class files.void
setDebugOptions
(DebugOptions debugOptions) Sets options for generating debugging information.void
setDeprecation
(boolean deprecation) Sets whether to log details of usage of deprecated members or classes.void
setEncoding
(String encoding) Sets the character encoding to be used when reading source files.void
setExtensionDirs
(String extensionDirs) Sets the extension dirs to be used for the compiler process.void
setFailOnError
(boolean failOnError) Sets whether to fail the build when compilation fails.void
setFork
(boolean fork) Sets whether to run the compiler in its own process.void
setForkOptions
(ForkOptions forkOptions) Sets options for running the compiler in a child process.setIncremental
(boolean incremental) Configure the java compilation to be incremental (e.g.void
setListFiles
(boolean listFiles) Sets whether to log the files to be compiled.void
setSourcepath
(FileCollection sourcepath) Sets the source path to use for the compilation.void
setVerbose
(boolean verbose) Sets whether to produce verbose output.void
setWarnings
(boolean warnings) Sets whether to log warning messages.Methods inherited from class org.gradle.api.tasks.compile.AbstractOptions
define
-
Constructor Details
-
CompileOptions
-
-
Method Details
-
isFailOnError
Tells whether to fail the build when compilation fails. Defaults totrue
. -
setFailOnError
public void setFailOnError(boolean failOnError) Sets whether to fail the build when compilation fails. Defaults totrue
. -
isVerbose
Tells whether to produce verbose output. Defaults tofalse
. -
setVerbose
public void setVerbose(boolean verbose) Sets whether to produce verbose output. Defaults tofalse
. -
isListFiles
Tells whether to log the files to be compiled. Defaults tofalse
. -
setListFiles
public void setListFiles(boolean listFiles) Sets whether to log the files to be compiled. Defaults tofalse
. -
isDeprecation
Tells whether to log details of usage of deprecated members or classes. Defaults tofalse
. -
setDeprecation
public void setDeprecation(boolean deprecation) Sets whether to log details of usage of deprecated members or classes. Defaults tofalse
. -
isWarnings
Tells whether to log warning messages. The default istrue
. -
setWarnings
public void setWarnings(boolean warnings) 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. -
setEncoding
Sets the character encoding to be used when reading source files. Defaults tonull
, in which case the platform default encoding will be used. -
isDebug
Tells whether to include debugging information in the generated class files. Defaults totrue
. SeeDebugOptions.getDebugLevel()
for which debugging information will be generated. -
setDebug
public void setDebug(boolean debug) 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. -
setDebugOptions
Sets options for generating debugging information. -
isFork
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
. -
setFork
public void setFork(boolean fork) 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. -
setForkOptions
Sets options for running the compiler in a child process. -
getBootClasspath
Deprecated.UsegetBootstrapClasspath()
instead.Returns the bootstrap classpath to be used for the compiler process. Defaults tonull
. -
setBootClasspath
Deprecated.UsesetBootstrapClasspath(FileCollection)
instead.Sets the bootstrap classpath to be used for the compiler process. Defaults tonull
. -
getBootstrapClasspath
Returns the bootstrap classpath to be used for the compiler process. Defaults tonull
.- Since:
- 4.3
-
setBootstrapClasspath
Sets the bootstrap classpath to be used for the compiler process. Defaults tonull
.- Since:
- 4.3
-
getExtensionDirs
Returns the extension dirs to be used for the compiler process. Defaults tonull
. -
setExtensionDirs
Sets 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--release
option of JDK 9:
Note that ifcompilerArgs.addAll(['--release', '7'])
--release
is added then-target
and-source
are ignored. -
setCompilerArgs
Sets any additional arguments to be passed to the compiler. Defaults to the empty list. -
fork
Convenience method to setForkOptions
with named parameter syntax. Calling this method will setfork
totrue
. -
debug
Convenience method to setDebugOptions
with named parameter syntax. Calling this method will setdebug
totrue
. -
setIncremental
Configure the java compilation to be incremental (e.g. compiles only those java classes that were changed or that are dependencies to the changed classes). -
optionMap
Internal method.- Overrides:
optionMap
in classAbstractOptions
-
excludeFromAntProperties
- Overrides:
excludeFromAntProperties
in classAbstractOptions
-
getAntPropertyName
- Overrides:
getAntPropertyName
in classAbstractOptions
-
getAntPropertyValue
- Overrides:
getAntPropertyValue
in classAbstractOptions
-
isIncremental
informs whether to use incremental compilation feature. SeesetIncremental(boolean)
-
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-sourcepath
option 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
- See Also:
-
setSourcepath
Sets the source path to use for the compilation.- Parameters:
sourcepath
- the source path
-
getAnnotationProcessorPath
Returns the classpath to use to load annotation processors. This path is also used for annotation processor discovery. The default value isnull
, which means use the compile classpath.- Returns:
- The annotation processor path, or
null
to use the default. - Since:
- 3.4
-
setAnnotationProcessorPath
@Incubating public void setAnnotationProcessorPath(@Nullable FileCollection annotationProcessorPath) Set the classpath to use to load annotation processors. This path is also used for annotation processor discovery. The value can benull
, which means use the compile classpath.- Parameters:
annotationProcessorPath
- The annotation processor path, ornull
to use the default.- Since:
- 3.4
-
getAnnotationProcessorGeneratedSourcesDirectory
@Optional @Nullable @Incubating @OutputDirectory public File getAnnotationProcessorGeneratedSourcesDirectory()Returns the directory to place source files generated by annotation compilers.- Since:
- 4.3
-
setAnnotationProcessorGeneratedSourcesDirectory
Sets the directory to place source files generated by annotation compilers.- Since:
- 4.3
-
setAnnotationProcessorGeneratedSourcesDirectory
Sets the directory to place source files generated by annotation compilers.- Since:
- 4.3
-
getBootstrapClasspath()
instead.