Save This Page
Home » apache-ant-1.7.1-src » org.apache.tools » ant » taskdefs » [javadoc | source]
org.apache.tools.ant.taskdefs
public class: Javac [javadoc | source]
java.lang.Object
   org.apache.tools.ant.ProjectComponent
      org.apache.tools.ant.Task
         org.apache.tools.ant.taskdefs.MatchingTask
            org.apache.tools.ant.taskdefs.Javac

All Implemented Interfaces:
    SelectorContainer, Cloneable

Direct Known Subclasses:
    Apt

Compiles Java source files. This task can take the following arguments: Of these arguments, the sourcedir and destdir are required.

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.

Nested Class Summary:
public class  Javac.ImplementationSpecificArgument  Adds an "compiler" attribute to Commandline$Attribute used to filter command line attributes based on the current implementation. 
Field Summary
protected  boolean failOnError     
protected  boolean listFiles     
protected  File[] compileList     
Fields inherited from org.apache.tools.ant.taskdefs.MatchingTask:
fileset
Fields inherited from org.apache.tools.ant.Task:
target,  taskName,  taskType,  wrapper
Fields inherited from org.apache.tools.ant.ProjectComponent:
project,  location,  description
Constructor:
 public Javac() 
Method from org.apache.tools.ant.taskdefs.Javac Summary:
checkParameters,   compile,   createBootclasspath,   createClasspath,   createCompilerArg,   createExtdirs,   createSourcepath,   createSrc,   execute,   getBootclasspath,   getClasspath,   getCompiler,   getCompilerVersion,   getCurrentCompilerArgs,   getDebug,   getDebugLevel,   getDepend,   getDeprecation,   getDestdir,   getEncoding,   getExecutable,   getExtdirs,   getFailonerror,   getFileList,   getIncludeantruntime,   getIncludejavaruntime,   getJavacExecutable,   getListfiles,   getMemoryInitialSize,   getMemoryMaximumSize,   getNowarn,   getOptimize,   getSource,   getSourcepath,   getSrcdir,   getSystemJavac,   getTarget,   getTaskSuccess,   getTempdir,   getVerbose,   isForkedJavac,   isIncludeDestClasses,   isJdkCompiler,   recreateSrc,   resetFileLists,   scanDir,   setBootClasspathRef,   setBootclasspath,   setClasspath,   setClasspathRef,   setCompiler,   setDebug,   setDebugLevel,   setDepend,   setDeprecation,   setDestdir,   setEncoding,   setErrorProperty,   setExecutable,   setExtdirs,   setFailonerror,   setFork,   setIncludeDestClasses,   setIncludeantruntime,   setIncludejavaruntime,   setListfiles,   setMemoryInitialSize,   setMemoryMaximumSize,   setNowarn,   setOptimize,   setProceed,   setSource,   setSourcepath,   setSourcepathRef,   setSrcdir,   setTarget,   setTempdir,   setUpdatedProperty,   setVerbose
Methods from org.apache.tools.ant.taskdefs.MatchingTask:
XsetIgnore,   XsetItems,   add,   addAnd,   addContains,   addContainsRegexp,   addCustom,   addDate,   addDepend,   addDepth,   addDifferent,   addFilename,   addMajority,   addModified,   addNone,   addNot,   addOr,   addPresent,   addSelector,   addSize,   addType,   appendSelector,   createExclude,   createExcludesFile,   createInclude,   createIncludesFile,   createPatternSet,   getDirectoryScanner,   getImplicitFileSet,   getSelectors,   hasSelectors,   selectorCount,   selectorElements,   setCaseSensitive,   setDefaultexcludes,   setExcludes,   setExcludesfile,   setFollowSymlinks,   setIncludes,   setIncludesfile,   setProject
Methods from org.apache.tools.ant.Task:
bindToOwner,   execute,   getOwningTarget,   getRuntimeConfigurableWrapper,   getTaskName,   getTaskType,   getWrapper,   handleErrorFlush,   handleErrorOutput,   handleFlush,   handleInput,   handleOutput,   init,   isInvalid,   log,   log,   log,   log,   markInvalid,   maybeConfigure,   perform,   reconfigure,   setOwningTarget,   setRuntimeConfigurableWrapper,   setTaskName,   setTaskType
Methods from org.apache.tools.ant.ProjectComponent:
clone,   getDescription,   getLocation,   getProject,   log,   log,   setDescription,   setLocation,   setProject
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.tools.ant.taskdefs.Javac Detail:
 protected  void checkParameters() throws BuildException 
    Check that all required attributes have been set and nothing silly has been entered.
 protected  void compile() 
    Perform the compilation.
 public Path createBootclasspath() 
    Adds a path to the bootclasspath.
 public Path createClasspath() 
    Adds a path to the classpath.
 public Javac.ImplementationSpecificArgument createCompilerArg() 
    Adds an implementation specific command-line argument.
 public Path createExtdirs() 
    Adds a path to extdirs.
 public Path createSourcepath() 
    Adds a path to sourcepath.
 public Path createSrc() 
    Adds a path for source compilation.
 public  void execute() throws BuildException 
    Executes the task.
 public Path getBootclasspath() 
    Gets the bootclasspath that will be used to compile the classes against.
 public Path getClasspath() 
    Gets the classpath to be used for this compilation.
 public String getCompiler() 
    The implementation for this particular task.

    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.

 public String getCompilerVersion() 
    The implementation for this particular task.

    Defaults to the build.compiler property but can be overridden via the compiler attribute.

    This method does not take the fork attribute into account.

 public String[] getCurrentCompilerArgs() 
    Get the additional implementation specific command line arguments.
 public boolean getDebug() 
    Gets the debug flag.
 public String getDebugLevel() 
    Get the value of debugLevel.
 public boolean getDepend() 
    Gets the depend flag.
 public boolean getDeprecation() 
    Gets the deprecation flag.
 public File getDestdir() 
    Gets the destination directory into which the java source files should be compiled.
 public String getEncoding() 
    Gets the java source file encoding name.
 public String getExecutable() 
    The value of the executable attribute, if any.
 public Path getExtdirs() 
    Gets the extension directories that will be used during the compilation.
 public boolean getFailonerror() 
    Gets the failonerror flag.
 public File[] getFileList() 
    Gets the list of files to be compiled.
 public boolean getIncludeantruntime() 
    Gets whether or not the ant classpath is to be included in the classpath.
 public boolean getIncludejavaruntime() 
    Gets whether or not the java runtime should be included in this task's classpath.
 public String getJavacExecutable() 
    The name of the javac executable to use in fork-mode.

    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.

 public boolean getListfiles() 
    Get the listfiles flag.
 public String getMemoryInitialSize() 
    Gets the memoryInitialSize flag.
 public String getMemoryMaximumSize() 
    Gets the memoryMaximumSize flag.
 public boolean getNowarn() 
    Should the -nowarn option be used.
 public boolean getOptimize() 
    Gets the optimize flag.
 public String getSource() 
    Get the value of source.
 public Path getSourcepath() 
    Gets the sourcepath to be used for this compilation.
 public Path getSrcdir() 
    Gets the source dirs to find the source java files.
 protected String getSystemJavac() 
 public String getTarget() 
    Gets the target VM that the classes will be compiled for.
 public boolean getTaskSuccess() 
    Get the result of the javac task (success or failure).
 public File getTempdir() 
    Where Ant should place temporary files.
 public boolean getVerbose() 
    Gets the verbose flag.
 public boolean isForkedJavac() 
    Is this a forked invocation of JDK's javac?
 public 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. The results are returned in the class variable compileList
 public  void setBootClasspathRef(Reference r) 
    Adds a reference to a classpath defined elsewhere.
 public  void setBootclasspath(Path bootclasspath) 
    Sets the bootclasspath that will be used to compile the classes against.
 public  void setClasspath(Path classpath) 
    Set the classpath to be used for this compilation.
 public  void setClasspathRef(Reference r) 
    Adds a reference to a classpath defined elsewhere.
 public  void setCompiler(String compiler) 
    Choose the implementation for this particular task.
 public  void setDebug(boolean debug) 
    Indicates whether source should be compiled with debug information; defaults to off.
 public  void setDebugLevel(String v) 
    Keyword list to be appended to the -g command-line switch. This will be ignored by all implementations except modern and classic(ver >= 1.2). Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debuglevel is not specified, by default, :none will be appended to -g. If debug is not turned on, this attribute will be ignored.
 public  void setDepend(boolean depend) 
    Enables dependency-tracking for compilers that support this (jikes and classic).
 public  void setDeprecation(boolean deprecation) 
    Indicates whether source should be compiled with deprecation information; defaults to off.
 public  void setDestdir(File destDir) 
    Set the destination directory into which the Java source files should be compiled.
 public  void setEncoding(String encoding) 
    Set the Java source file encoding name.
 public  void setErrorProperty(String errorProperty) 
    The property to set on compliation failure. This property will be set if the compilation fails.
 public  void setExecutable(String forkExec) 
    Sets the name of the javac executable.

    Ignored unless fork is true or extJavac has been specified as the compiler.

 public  void setExtdirs(Path extdirs) 
    Sets the extension directories that will be used during the compilation.
 public  void setFailonerror(boolean fail) 
    Indicates whether the build will continue even if there are compilation errors; defaults to true.
 public  void setFork(boolean f) 
    If true, forks the javac compiler.
 public  void setIncludeDestClasses(boolean includeDestClasses) 
    This property controls whether to include the destination classes directory in the classpath given to the compiler. The default value is "true".
 public  void setIncludeantruntime(boolean include) 
    If true, includes Ant's own classpath in the classpath.
 public  void setIncludejavaruntime(boolean include) 
    If true, includes the Java runtime libraries in the classpath.
 public  void setListfiles(boolean list) 
    If true, list the source files being handed off to the compiler.
 public  void setMemoryInitialSize(String memoryInitialSize) 
    The initial size of the memory for the underlying VM if javac is run externally; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
 public  void setMemoryMaximumSize(String memoryMaximumSize) 
    The maximum size of the memory for the underlying VM if javac is run externally; ignored otherwise. Defaults to the standard VM memory setting. (Examples: 83886080, 81920k, or 80m)
 public  void setNowarn(boolean flag) 
    If true, enables the -nowarn option.
 public  void setOptimize(boolean optimize) 
    If true, compiles with optimization enabled.
 public  void setProceed(boolean proceed) 
 public  void setSource(String v) 
    Value of the -source command-line switch; will be ignored by all implementations except modern and jikes. If you use this attribute together with jikes, 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.
 public  void setSourcepath(Path sourcepath) 
    Set the sourcepath to be used for this compilation.
 public  void setSourcepathRef(Reference r) 
    Adds a reference to a source path defined elsewhere.
 public  void setSrcdir(Path srcDir) 
    Set the source directories to find the source Java files.
 public  void setTarget(String target) 
    Sets the target VM that the classes will be compiled for. Valid values depend on the compiler, for jdk 1.4 the valid values are "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "5" and "6".
 public  void setTempdir(File tmpDir) 
    Where Ant should place temporary files.
 public  void setUpdatedProperty(String updatedProperty) 
    The property to set on compliation success. This property will not be set if the compilation fails, or if there are no files to compile.
 public  void setVerbose(boolean verbose) 
    If true, asks the compiler for verbose output.