org.apache.tools.ant.taskdefs
Class Javac

java.lang.Object
  |
  +--org.apache.tools.ant.Task
        |
        +--org.apache.tools.ant.taskdefs.MatchingTask
              |
              +--org.apache.tools.ant.taskdefs.Javac
Direct Known Subclasses:
CompileTask

public class Javac
extends MatchingTask

Task to compile 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.

Author:
James Davidson duncan@x180.com, Robin Green greenrd@hotmail.com

Field Summary
protected  java.util.Vector compileList
           
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset, useDefaultExcludes
 
Fields inherited from class org.apache.tools.ant.Task
description, location, project, target, taskName, taskType, wrapper
 
Constructor Summary
Javac()
           
 
Method Summary
protected  void addExtdirsToClasspath(Path classpath)
          Emulation of extdirs feature in java >= 1.2.
 Path createBootclasspath()
          Maybe creates a nested classpath element.
 Path createClasspath()
          Maybe creates a nested classpath element.
 Path createExtdirs()
          Maybe creates a nested classpath element.
 Path createSrc()
          Create a nested element for multiple source path support.
 void execute()
          Executes the task.
protected  int executeJikesCompile(java.lang.String[] args, int firstFileName)
          Do the compile with the specified arguments.
protected  Path getCompileClasspath(boolean addRuntime)
          Builds the compilation classpath.
protected  void logAndAddFilesToCompile(Commandline cmd)
          Logs the compilation parameters, adds the files to compile and logs the &qout;niceSourceList"
protected  void resetFileLists()
          Clear the list of files to be compiled and copied..
protected  void scanDir(java.io.File srcDir, java.io.File destDir, java.lang.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 setDebug(boolean debug)
          Set the debug flag.
 void setDepend(boolean depend)
          Set the depend flag.
 void setDeprecation(boolean deprecation)
          Set the deprecation flag.
 void setDestdir(java.io.File destDir)
          Set the destination directory into which the Java source files should be compiled.
 void setEncoding(java.lang.String encoding)
          Set the Java source file encoding name.
 void setExtdirs(Path extdirs)
          Sets the extension directories that will be used during the compilation.
 void setOptimize(boolean optimize)
          Set the optimize flag.
 void setSrcdir(Path srcDir)
          Set the source dirs to find the source Java files.
 void setTarget(java.lang.String target)
          Sets the target VM that the classes will be compiled for.
 void setVerbose(boolean verbose)
          Set the verbose flag.
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
createExclude, createInclude, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getProject, getRuntimeConfigurableWrapper, getTaskName, init, log, log, maybeConfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compileList

protected java.util.Vector compileList
Constructor Detail

Javac

public Javac()
Method Detail

createSrc

public Path createSrc()
Create a nested element for multiple source path support.
Returns:
a nexted src element.

setSrcdir

public void setSrcdir(Path srcDir)
Set the source dirs to find the source Java files.

setDestdir

public void setDestdir(java.io.File destDir)
Set the destination directory into which the Java source files should be compiled.

setClasspath

public void setClasspath(Path classpath)
Set the classpath to be used for this compilation.

createClasspath

public Path createClasspath()
Maybe creates a nested classpath element.

setClasspathRef

public void setClasspathRef(Reference r)
Adds a reference to a CLASSPATH defined elsewhere.

setBootclasspath

public void setBootclasspath(Path bootclasspath)
Sets the bootclasspath that will be used to compile the classes against.

createBootclasspath

public Path createBootclasspath()
Maybe creates a nested classpath element.

setBootClasspathRef

public void setBootClasspathRef(Reference r)
Adds a reference to a CLASSPATH defined elsewhere.

setExtdirs

public void setExtdirs(Path extdirs)
Sets the extension directories that will be used during the compilation.

createExtdirs

public Path createExtdirs()
Maybe creates a nested classpath element.

setDeprecation

public void setDeprecation(boolean deprecation)
Set the deprecation flag.

setEncoding

public void setEncoding(java.lang.String encoding)
Set the Java source file encoding name.

setDebug

public void setDebug(boolean debug)
Set the debug flag.

setOptimize

public void setOptimize(boolean optimize)
Set the optimize flag.

setDepend

public void setDepend(boolean depend)
Set the depend flag.

setVerbose

public void setVerbose(boolean verbose)
Set the verbose flag.

setTarget

public void setTarget(java.lang.String target)
Sets the target VM that the classes will be compiled for. Valid strings are "1.1", "1.2", and "1.3".

execute

public void execute()
             throws BuildException
Executes the task.
Overrides:
execute in class Task
Following copied from class: org.apache.tools.ant.Task
Throws:
BuildException - if someting goes wrong with the build

resetFileLists

protected void resetFileLists()
Clear the list of files to be compiled and copied..

scanDir

protected void scanDir(java.io.File srcDir,
                       java.io.File destDir,
                       java.lang.String[] files)
Scans the directory looking for source files to be compiled. The results are returned in the class variable compileList

getCompileClasspath

protected Path getCompileClasspath(boolean addRuntime)
Builds the compilation classpath.
Parameters:
addRuntime - Shall rt.jar or classes.zip be added to the classpath.

logAndAddFilesToCompile

protected void logAndAddFilesToCompile(Commandline cmd)
Logs the compilation parameters, adds the files to compile and logs the &qout;niceSourceList"

executeJikesCompile

protected int executeJikesCompile(java.lang.String[] args,
                                  int firstFileName)
Do the compile with the specified arguments.
Parameters:
args - - arguments to pass to process on command line
firstFileName - - index of the first source file in args

addExtdirsToClasspath

protected void addExtdirsToClasspath(Path classpath)
Emulation of extdirs feature in java >= 1.2. This method adds all files in the given directories (but not in sub-directories!) to the classpath, so that you don't have to specify them all one by one.
Parameters:
classpath - - Path to append files to


Copyright © 2000 Apache Software Foundation. All Rights Reserved.