org.apache.tools.ant.taskdefs
public class Javac extends MatchingTask
When this task executes, it will recursively scan the sourcedir and destdir looking for Java source files to compile. This task makes its compile decision based on timestamp.
Since: Ant 1.1
UNKNOWN: category="java"
Nested Class Summary | |
---|---|
class | Javac.ImplementationSpecificArgument
Adds an "compiler" attribute to Commandline$Attribute used to
filter command line attributes based on the current
implementation. |
Field Summary | |
---|---|
protected File[] | compileList |
protected boolean | failOnError |
protected boolean | listFiles |
Constructor Summary | |
---|---|
Javac()
Javac task for compilation of Java files. |
Method Summary | |
---|---|
void | add(CompilerAdapter adapter)
Set the compiler adapter explicitly. |
protected void | checkParameters()
Check that all required attributes have been set and nothing
silly has been entered.
|
protected void | compile()
Perform the compilation.
|
Path | createBootclasspath()
Adds a path to the bootclasspath. |
Path | createClasspath()
Adds a path to the classpath. |
Javac.ImplementationSpecificArgument | createCompilerArg()
Adds an implementation specific command-line argument. |
Path | createCompilerClasspath()
The classpath to use when loading the compiler implementation
if it is not a built-in one.
|
Path | createExtdirs()
Adds a path to extdirs. |
Path | createSourcepath()
Adds a path to sourcepath. |
Path | createSrc()
Adds a path for source compilation.
|
void | execute()
Executes the task. |
Path | getBootclasspath()
Gets the bootclasspath that will be used to compile the classes
against. |
Path | getClasspath()
Gets the classpath to be used for this compilation. |
String | getCompiler()
The implementation for this particular task.
|
String | getCompilerVersion()
The implementation for this particular task.
|
String[] | getCurrentCompilerArgs()
Get the additional implementation specific command line arguments. |
boolean | getDebug()
Gets the debug flag. |
String | getDebugLevel()
Get the value of debugLevel. |
boolean | getDepend()
Gets the depend flag. |
boolean | getDeprecation()
Gets the deprecation flag. |
File | getDestdir()
Gets the destination directory into which the java source files
should be compiled. |
String | getEncoding()
Gets the java source file encoding name. |
String | getExecutable()
The value of the executable attribute, if any.
|
Path | getExtdirs()
Gets the extension directories that will be used during the
compilation. |
boolean | getFailonerror()
Gets the failonerror flag. |
File[] | getFileList()
Gets the list of files to be compiled. |
boolean | getIncludeantruntime()
Gets whether or not the ant classpath is to be included in the classpath. |
boolean | getIncludejavaruntime()
Gets whether or not the java runtime should be included in this
task's classpath. |
String | getJavacExecutable()
The name of the javac executable to use in fork-mode.
|
boolean | getListfiles()
Get the listfiles flag. |
String | getMemoryInitialSize()
Gets the memoryInitialSize flag. |
String | getMemoryMaximumSize()
Gets the memoryMaximumSize flag. |
boolean | getNowarn()
Should the -nowarn option be used. |
boolean | getOptimize()
Gets the optimize flag. |
String | getSource()
Get the value of source. |
Path | getSourcepath()
Gets the sourcepath to be used for this compilation. |
Path | getSrcdir()
Gets the source dirs to find the source java files. |
protected String | getSystemJavac() |
String | getTarget()
Gets the target VM that the classes will be compiled for. |
boolean | getTaskSuccess()
Get the result of the javac task (success or failure). |
File | getTempdir()
Where Ant should place temporary files.
|
boolean | getVerbose()
Gets the verbose flag. |
boolean | isForkedJavac()
Is this a forked invocation of JDK's javac? |
boolean | isIncludeDestClasses()
Get the value of the includeDestClasses property. |
protected boolean | isJdkCompiler(String compilerImpl)
Is the compiler implementation a jdk compiler
|
protected Path | recreateSrc()
Recreate src.
|
protected void | resetFileLists()
Clear the list of files to be compiled and copied.. |
protected void | scanDir(File srcDir, File destDir, String[] files)
Scans the directory looking for source files to be compiled.
|
void | setBootclasspath(Path bootclasspath)
Sets the bootclasspath that will be used to compile the classes
against. |
void | setBootClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere. |
void | setClasspath(Path classpath)
Set the classpath to be used for this compilation.
|
void | setClasspathRef(Reference r)
Adds a reference to a classpath defined elsewhere. |
void | setCompiler(String compiler)
Choose the implementation for this particular task. |
void | setCreateMissingPackageInfoClass(boolean b)
Whether package-info.class files will be created by Ant
matching package-info.java files that have been compiled but
didn't create class files themselves.
|
void | setDebug(boolean debug)
Indicates whether source should be compiled
with debug information; defaults to off. |
void | setDebugLevel(String v)
Keyword list to be appended to the -g command-line switch.
|
void | setDepend(boolean depend)
Enables dependency-tracking for compilers
that support this (jikes and classic). |
void | setDeprecation(boolean deprecation)
Indicates whether source should be
compiled with deprecation information; defaults to off. |
void | setDestdir(File destDir)
Set the destination directory into which the Java source
files should be compiled. |
void | setEncoding(String encoding)
Set the Java source file encoding name. |
void | setErrorProperty(String errorProperty)
The property to set on compilation failure.
|
void | setExecutable(String forkExec)
Sets the name of the javac executable.
|
void | setExtdirs(Path extdirs)
Sets the extension directories that will be used during the
compilation. |
void | setFailonerror(boolean fail)
Indicates whether the build will continue
even if there are compilation errors; defaults to true. |
void | setFork(boolean f)
If true, forks the javac compiler.
|
void | setIncludeantruntime(boolean include)
If true, includes Ant's own classpath in the classpath. |
void | setIncludeDestClasses(boolean includeDestClasses)
This property controls whether to include the
destination classes directory in the classpath
given to the compiler.
|
void | setIncludejavaruntime(boolean include)
If true, includes the Java runtime libraries in the classpath. |
void | setListfiles(boolean list)
If true, list the source files being handed off to the compiler. |
void | setMemoryInitialSize(String memoryInitialSize)
The initial size of the memory for the underlying VM
if javac is run externally; ignored otherwise.
|
void | setMemoryMaximumSize(String memoryMaximumSize)
The maximum size of the memory for the underlying VM
if javac is run externally; ignored otherwise.
|
void | setNowarn(boolean flag)
If true, enables the -nowarn option. |
void | setOptimize(boolean optimize)
If true, compiles with optimization enabled. |
void | setProceed(boolean proceed) |
void | setSource(String v)
Value of the -source command-line switch; will be ignored by
all implementations except modern, jikes and gcj (gcj uses
-fsource).
|
void | setSourcepath(Path sourcepath)
Set the sourcepath to be used for this compilation. |
void | setSourcepathRef(Reference r)
Adds a reference to a source path defined elsewhere. |
void | setSrcdir(Path srcDir)
Set the source directories to find the source Java files. |
void | setTarget(String target)
Sets the target VM that the classes will be compiled for. |
void | setTempdir(File tmpDir)
Where Ant should place temporary files.
|
void | setUpdatedProperty(String updatedProperty)
The property to set on compilation success.
|
void | setVerbose(boolean verbose)
If true, asks the compiler for verbose output. |
Since: Ant 1.8.0
Throws: BuildException if an error occurs
Since: Ant 1.5
Since: Ant 1.5
Returns: a path to be configured
Returns: a class path to be configured
Returns: a ImplementationSpecificArgument to be configured
Since: Ant 1.8.0
Returns: a path to be configured
Returns: a sourcepath to be configured
Returns: a nested src element.
Throws: BuildException if an error occurs
Returns: the boot path
Returns: the class path
Defaults to the build.compiler property but can be overridden via the compiler and fork attributes.
If fork has been set to true, the result will be extJavac and not classic or java1.2 - no matter what the compiler attribute looks like.
Returns: the compiler.
Since: Ant 1.5
See Also: Javac
Defaults to the build.compiler property but can be overridden via the compiler attribute.
This method does not take the fork attribute into account.
Returns: the compiler.
Since: Ant 1.5
See Also: Javac
Returns: array of command line arguments, guaranteed to be non-null.
Returns: the debug flag
Returns: value of debugLevel.
Returns: the depend flag
Returns: the deprecation flag
Returns: the destination directory
Returns: the source file encoding name
Returns: the name of the java executable
Since: Ant 1.6
Returns: the extension directories as a path
Returns: the failonerror flag
Returns: the list of files as an array
Returns: whether or not the ant classpath is to be included in the classpath
Returns: the includejavaruntime attribute
This is either the name specified with the executable attribute or the full path of the javac compiler of the VM Ant is currently running in - guessed by Ant.
You should not invoke this method if you
want to get the value of the executable command - use getExecutable
for this.
Returns: the name of the javac executable
Returns: the listfiles flag
Returns: the memoryInitialSize flag
Returns: the memoryMaximumSize flag
Returns: true if the -nowarn option should be used
Returns: the optimize flag
Returns: value of source.
Returns: the source path
Returns: the source directories as a path
Returns: the executable name of the java compiler
Returns: the target VM
Returns: true if compilation succeeded, or was not neccessary, false if the compilation failed.
Returns: the temporary directory
Since: Ant 1.6
Returns: the verbose flag
Returns: true if this is a forked invocation
Returns: the value.
Parameters: compilerImpl the name of the compiler implementation
Returns: true if compilerImpl is "modern", "classic", "javac1.1", "javac1.2", "javac1.3", "javac1.4", "javac1.5" or "javac1.6".
Returns: a nested src element.
Parameters: srcDir The source directory destDir The destination directory files An array of filenames
Parameters: bootclasspath a path to use as a boot class path (may be more than one)
Parameters: r a reference to a classpath
Parameters: classpath an Ant Path object containing the compilation classpath.
Parameters: r a reference to a classpath
Parameters: compiler the name of the compiler
Since: Ant 1.5
Since: Ant 1.8.3
Parameters: debug if true compile with debug information
Parameters: v Value to assign to debugLevel.
Parameters: depend if true enable dependency-tracking
Parameters: deprecation if true turn on deprecation information
Parameters: destDir the destination director
Parameters: encoding the source file encoding
Parameters: errorProperty the property name to use.
Since: Ant 1.7.1.
Ignored unless fork is true or extJavac has been specified as the compiler.
Parameters: forkExec the name of the executable
Parameters: extdirs a path
Parameters: fail if true halt the build on failure
Parameters: f "true|false|on|off|yes|no"
Parameters: include if true, includes Ant's own classpath in the classpath
Parameters: includeDestClasses the value to use.
Parameters: include if true, includes the Java runtime libraries in the classpath
Parameters: list if true list the source files
Parameters: memoryInitialSize string to pass to VM
Parameters: memoryMaximumSize string to pass to VM
Parameters: flag if true, enable the -nowarn option
Parameters: optimize if true compile with optimization enabled
Parameters: proceed inverse of failoferror
UNKNOWN: ignore="true"
If you use this attribute together with jikes or gcj, you must make sure that your version of jikes supports the -source switch.
Legal values are 1.3, 1.4, 1.5, and 5 - by default, no -source argument will be used at all.
Parameters: v Value to assign to source.
Parameters: sourcepath the source path
Parameters: r a reference to a source path
Parameters: srcDir the source directories as a path
Parameters: target the target VM
Parameters: tmpDir the temporary directory
Since: Ant 1.6
Parameters: updatedProperty the property name to use.
Since: Ant 1.7.1.
Parameters: verbose if true, asks the compiler for verbose output