Class CompileOptions
- All Implemented Interfaces:
- Serializable
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionDeprecated.This method will be removed in Gradle 9.0voiddebugOptions(Action<? super DebugOptions> action) Execute the given action againstgetDebugOptions().Deprecated.This method will be removed in Gradle 9.0voidforkOptions(Action<? super ForkOptions> action) Execute the given action againstgetForkOptions().Returns all compiler arguments, added to thegetCompilerArgs()or thegetCompilerArgumentProviders()property.Deprecated.UsegetGeneratedSourceOutputDirectory()instead.Returns the classpath to use to load annotation processors.Returns the bootstrap classpath to be used for the compiler process.Returns any additional arguments to be passed to the compiler.Compiler argument providers.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.Returns the directory to place source files generated by annotation processors.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.Used to enable or disable incremental compilation after a failure.Set the main class of the Java module, if the module is supposed to be executable.Set the version of the Java module.Configures the Java language version for this compile task (--releasecompiler flag).The source path to use for the compilation.booleanisDebug()Tells whether to include debugging information in the generated class files.booleanTells whether to log details of usage of deprecated members or classes.booleanTells whether to fail the build when compilation fails.booleanisFork()Tells whether to run the compiler in its own process.booleaninforms whether to use incremental compilation feature.booleanTells whether to log the files to be compiled.booleanTells whether to produce verbose output.booleanTells whether to log warning messages.voidDeprecated.UsegetGeneratedSourceOutputDirectory().set() instead.voidDeprecated.UsegetGeneratedSourceOutputDirectory().set() instead.voidsetAnnotationProcessorPath(FileCollection annotationProcessorPath) Set the classpath to use to load annotation processors.voidsetBootstrapClasspath(FileCollection bootstrapClasspath) Sets the bootstrap classpath to be used for the compiler process.voidsetCompilerArgs(List<String> compilerArgs) Sets any additional arguments to be passed to the compiler.voidsetDebug(boolean debug) Sets whether to include debugging information in the generated class files.voidsetDebugOptions(DebugOptions debugOptions) Deprecated.Setting a new instance of this property is unnecessary.voidsetDeprecation(boolean deprecation) Sets whether to log details of usage of deprecated members or classes.voidsetEncoding(String encoding) Sets the character encoding to be used when reading source files.voidsetExtensionDirs(String extensionDirs) Sets the extension dirs to be used for the compiler process.voidsetFailOnError(boolean failOnError) Sets whether to fail the build when compilation fails.voidsetFork(boolean fork) Sets whether to run the compiler in its own process.voidsetForkOptions(ForkOptions forkOptions) Deprecated.Setting a new instance of this property is unnecessary.setIncremental(boolean incremental) Configure the java compilation to be incremental (e.g.voidsetListFiles(boolean listFiles) Sets whether to log the files to be compiled.voidsetSourcepath(FileCollection sourcepath) Sets the source path to use for the compilation.voidsetVerbose(boolean verbose) Sets whether to produce verbose output.voidsetWarnings(boolean warnings) Sets whether to log warning messages.Methods inherited from class org.gradle.api.tasks.compile.AbstractOptionsdefine
- 
Constructor Details- 
CompileOptions
 
- 
- 
Method Details- 
isFailOnErrorTells whether to fail the build when compilation fails. Defaults totrue.
- 
setFailOnErrorpublic void setFailOnError(boolean failOnError) Sets whether to fail the build when compilation fails. Defaults totrue.
- 
isVerboseTells whether to produce verbose output. Defaults tofalse.
- 
setVerbosepublic void setVerbose(boolean verbose) Sets whether to produce verbose output. Defaults tofalse.
- 
isListFilesTells whether to log the files to be compiled. Defaults tofalse.
- 
setListFilespublic void setListFiles(boolean listFiles) Sets whether to log the files to be compiled. Defaults tofalse.
- 
isDeprecationTells whether to log details of usage of deprecated members or classes. Defaults tofalse.
- 
setDeprecationpublic void setDeprecation(boolean deprecation) Sets whether to log details of usage of deprecated members or classes. Defaults tofalse.
- 
isWarningsTells whether to log warning messages. The default istrue.
- 
setWarningspublic void setWarnings(boolean warnings) Sets whether to log warning messages. The default istrue.
- 
getEncodingReturns the character encoding to be used when reading source files. Defaults tonull, in which case the platform default encoding will be used.
- 
setEncodingSets the character encoding to be used when reading source files. Defaults tonull, in which case the platform default encoding will be used.
- 
isDebugTells whether to include debugging information in the generated class files. Defaults totrue. SeeDebugOptions.getDebugLevel()for which debugging information will be generated.
- 
setDebugpublic 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.
- 
getDebugOptionsReturns options for generating debugging information.
- 
setDebugOptionsDeprecated.Setting a new instance of this property is unnecessary. This method will be removed in Gradle 9.0. UsedebugOptions(Action)instead.Sets options for generating debugging information.
- 
debugOptionsExecute the given action againstgetDebugOptions().- Since:
- 8.11
 
- 
isForkTells 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.
- 
setForkpublic 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.
- 
getForkOptionsReturns options for running the compiler in a child process.
- 
setForkOptionsDeprecated.Setting a new instance of this property is unnecessary. This method will be removed in Gradle 9.0. UseforkOptions(Action)instead.Sets options for running the compiler in a child process.
- 
forkOptionsExecute the given action againstgetForkOptions().- Since:
- 8.11
 
- 
getBootstrapClasspathReturns the bootstrap classpath to be used for the compiler process. Defaults tonull.- Since:
- 4.3
 
- 
setBootstrapClasspathSets the bootstrap classpath to be used for the compiler process. Defaults tonull.- Since:
- 4.3
 
- 
getExtensionDirsReturns the extension dirs to be used for the compiler process. Defaults tonull.
- 
setExtensionDirsSets the extension dirs to be used for the compiler process. Defaults tonull.
- 
getCompilerArgsReturns 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.
- 
getAllCompilerArgsReturns all compiler arguments, added to thegetCompilerArgs()or thegetCompilerArgumentProviders()property.- Since:
- 4.5
 
- 
getCompilerArgumentProvidersCompiler argument providers.- Since:
- 4.5
 
- 
setCompilerArgsSets any additional arguments to be passed to the compiler. Defaults to the empty list.
- 
forkDeprecated.This method will be removed in Gradle 9.0Convenience method to setForkOptionswith named parameter syntax. Calling this method will setforktotrue.
- 
debugDeprecated.This method will be removed in Gradle 9.0Convenience method to setDebugOptionswith named parameter syntax. Calling this method will setdebugtotrue.
- 
setIncrementalConfigure the java compilation to be incremental (e.g. compiles only those java classes that were changed or that are dependencies to the changed classes).
- 
isIncrementalinforms whether to use incremental compilation feature. SeesetIncremental(boolean)
- 
getIncrementalAfterFailureUsed 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 @Nullable @IgnoreEmptyDirectories @PathSensitive(RELATIVE) @InputFiles public FileCollection 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
- See Also:
 
- 
setSourcepathSets the source path to use for the compilation.- Parameters:
- sourcepath- the source path
 
- 
getAnnotationProcessorPathReturns 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
 
- 
setAnnotationProcessorPathSet the classpath to use to load annotation processors. This path is also used for annotation processor discovery.- Parameters:
- annotationProcessorPath- The annotation processor path, or- nullto disable annotation processing.
- Since:
- 3.4
 
- 
getReleaseConfigures 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
 
- 
getJavaModuleVersionSet the version of the Java module.- Since:
- 6.4
 
- 
getJavaModuleMainClassSet the main class of the Java module, if the module is supposed to be executable.- Since:
- 6.4
 
- 
getGeneratedSourceOutputDirectoryReturns the directory to place source files generated by annotation processors.- Since:
- 6.3
 
- 
getAnnotationProcessorGeneratedSourcesDirectory@Nullable @Deprecated @ReplacedBy("generatedSourceOutputDirectory") public File getAnnotationProcessorGeneratedSourcesDirectory()Deprecated.UsegetGeneratedSourceOutputDirectory()instead. This method will be removed in Gradle 9.0.Returns the directory to place source files generated by annotation processors.- Since:
- 4.3
 
- 
setAnnotationProcessorGeneratedSourcesDirectoryDeprecated.UsegetGeneratedSourceOutputDirectory().set() instead. This method will be removed in Gradle 9.0.Sets the directory to place source files generated by annotation processors.- Since:
- 4.3
 
- 
setAnnotationProcessorGeneratedSourcesDirectoryDeprecated.UsegetGeneratedSourceOutputDirectory().set() instead. This method will be removed in Gradle 9.0.Sets the directory to place source files generated by annotation processors.- Since:
- 4.3
 
- 
getHeaderOutputDirectoryIf 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
 
 
-