public class CompileOptions extends AbstractOptions
Constructor and Description |
---|
CompileOptions(ObjectFactory objectFactory) |
Modifier and Type | Method and Description |
---|---|
CompileOptions |
debug(Map<String,Object> debugArgs)
Convenience method to set
DebugOptions with named parameter syntax. |
protected boolean |
excludeFromAntProperties(String fieldName) |
CompileOptions |
fork(Map<String,Object> forkArgs)
Convenience method to set
ForkOptions with named parameter syntax. |
List<String> |
getAllCompilerArgs()
Returns all compiler arguments, added to the
getCompilerArgs() or the getCompilerArgumentProviders() property. |
File |
getAnnotationProcessorGeneratedSourcesDirectory()
Returns the directory to place source files generated by annotation compilers.
|
FileCollection |
getAnnotationProcessorPath()
Returns the classpath to use to load annotation processors.
|
protected String |
getAntPropertyName(String fieldName) |
protected Object |
getAntPropertyValue(String fieldName,
Object value) |
String |
getBootClasspath()
Deprecated.
Use
getBootstrapClasspath() instead. |
FileCollection |
getBootstrapClasspath()
Returns the bootstrap classpath to be used for the compiler process.
|
List<String> |
getCompilerArgs()
Returns any additional arguments to be passed to the compiler.
|
List<CommandLineArgumentProvider> |
getCompilerArgumentProviders()
Compiler argument providers.
|
DebugOptions |
getDebugOptions()
Returns options for generating debugging information.
|
String |
getEncoding()
Returns the character encoding to be used when reading source files.
|
String |
getExtensionDirs()
Returns the extension dirs to be used for the compiler process.
|
ForkOptions |
getForkOptions()
Returns options for running the compiler in a child process.
|
FileCollection |
getSourcepath()
The source path to use for the compilation.
|
boolean |
isDebug()
Tells whether to include debugging information in the generated class files.
|
boolean |
isDeprecation()
Tells whether to log details of usage of deprecated members or classes.
|
boolean |
isFailOnError()
Tells whether to fail the build when compilation fails.
|
boolean |
isFork()
Tells whether to run the compiler in its own process.
|
boolean |
isIncremental()
informs whether to use incremental compilation feature.
|
boolean |
isListFiles()
Tells whether to log the files to be compiled.
|
boolean |
isVerbose()
Tells whether to produce verbose output.
|
boolean |
isWarnings()
Tells whether to log warning messages.
|
Map<String,Object> |
optionMap()
Internal method.
|
void |
setAnnotationProcessorGeneratedSourcesDirectory(File file)
Sets the directory to place source files generated by annotation compilers.
|
void |
setAnnotationProcessorGeneratedSourcesDirectory(Provider<File> file)
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.
Use
setBootstrapClasspath(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.
|
CompileOptions |
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.
|
define
@Inject public CompileOptions(ObjectFactory objectFactory)
@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
.@Console public boolean isDeprecation()
false
.public void setDeprecation(boolean deprecation)
false
.@Console public boolean isWarnings()
true
.public void setWarnings(boolean warnings)
true
.@Input @Optional public String getEncoding()
null
, in which
case the platform default encoding will be used.public void setEncoding(String encoding)
null
, in which
case the platform default encoding will be used.@Input public boolean isDebug()
true
. See DebugOptions.getDebugLevel()
for which debugging information will be generated.public void setDebug(boolean debug)
true
. See DebugOptions.getDebugLevel()
for which debugging information will be generated.public DebugOptions getDebugOptions()
public void setDebugOptions(DebugOptions debugOptions)
@Input public boolean isFork()
false
.public void setFork(boolean fork)
false
.public ForkOptions getForkOptions()
public void setForkOptions(ForkOptions forkOptions)
@Deprecated @Internal public String getBootClasspath()
getBootstrapClasspath()
instead.null
.@Deprecated public void setBootClasspath(String bootClasspath)
setBootstrapClasspath(FileCollection)
instead.null
.@Optional @CompileClasspath public FileCollection getBootstrapClasspath()
null
.public void setBootstrapClasspath(FileCollection bootstrapClasspath)
null
.@Input @Optional public String getExtensionDirs()
null
.public void setExtensionDirs(String extensionDirs)
null
.@Input public List<String> getCompilerArgs()
--release
option of JDK 9:
compilerArgs.addAll(['--release', '7'])
Note that if --release
is added then -target
and -source
are ignored.@Incubating @Internal public List<String> getAllCompilerArgs()
getCompilerArgs()
or the getCompilerArgumentProviders()
property.@Incubating public List<CommandLineArgumentProvider> getCompilerArgumentProviders()
public void setCompilerArgs(List<String> compilerArgs)
public CompileOptions fork(Map<String,Object> forkArgs)
ForkOptions
with named parameter syntax.
Calling this method will set fork
to true
.public CompileOptions debug(Map<String,Object> debugArgs)
DebugOptions
with named parameter syntax.
Calling this method will set debug
to true
.public CompileOptions setIncremental(boolean incremental)
public Map<String,Object> optionMap()
optionMap
in class AbstractOptions
protected boolean excludeFromAntProperties(String fieldName)
excludeFromAntProperties
in class AbstractOptions
protected String getAntPropertyName(String fieldName)
getAntPropertyName
in class AbstractOptions
protected Object getAntPropertyValue(String fieldName, Object value)
getAntPropertyValue
in class AbstractOptions
@Internal public boolean isIncremental()
setIncremental(boolean)
@PathSensitive(value=RELATIVE) @InputFiles @Optional @Incubating public FileCollection getSourcepath()
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.
setSourcepath(FileCollection)
@Incubating public void setSourcepath(FileCollection sourcepath)
sourcepath
- the source path@Optional @Internal @Nullable public FileCollection getAnnotationProcessorPath()
null
, it means use the compile classpath.null
to use the compile classpath.public void setAnnotationProcessorPath(@Nullable FileCollection annotationProcessorPath)
null
, which means use the compile classpath.annotationProcessorPath
- The annotation processor path, or null
to use the compile classpath.@Optional @Nullable @Incubating @OutputDirectory public File getAnnotationProcessorGeneratedSourcesDirectory()
@Incubating public void setAnnotationProcessorGeneratedSourcesDirectory(File file)
@Incubating public void setAnnotationProcessorGeneratedSourcesDirectory(Provider<File> file)