org.apache.tools.ant.taskdefs
Class Javac

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
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, Stefan Bodewig, J D Glanville

Field Summary
protected  java.io.File[] compileList
           
protected  boolean failOnError
           
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset, useDefaultExcludes
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
Javac()
           
 
Method Summary
 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.
 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.
 boolean getDebug()
          Gets the debug flag.
 boolean getDepend()
          Gets the depend flag.
 boolean getDeprecation()
          Gets the deprecation flag.
 java.io.File getDestdir()
          Gets the destination directory into which the java source files should be compiled.
 java.lang.String getEncoding()
          Gets the java source file encoding name.
 Path getExtdirs()
          Gets the extension directories that will be used during the compilation.
 boolean getFailonerror()
          Gets the failonerror flag.
 java.io.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 task's classpath.
 boolean getIncludejavaruntime()
          Gets whether or not the java runtime should be included in this task's classpath.
 java.lang.String getMemoryInitialSize()
          Gets the memoryInitialSize flag.
 java.lang.String getMemoryMaximumSize()
          Gets the memoryMaximumSize flag.
 boolean getNowarn()
          Should the -nowarn option be used.
 boolean getOptimize()
          Gets the optimize flag.
 java.lang.String getSource()
          Get the value of source.
 Path getSrcdir()
          Gets the source dirs to find the source java files.
 java.lang.String getTarget()
          Gets the target VM that the classes will be compiled for.
 boolean getVerbose()
          Gets the verbose flag.
 boolean isForkedJavac()
          Is this a forked invocation of JDK's javac?
protected  boolean isJdkCompiler(java.lang.String compiler)
           
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 setFailonerror(boolean fail)
          Throw a BuildException if compilation fails
 void setFork(boolean fork)
          Sets whether to fork the javac compiler.
 void setIncludeantruntime(boolean include)
          Include ant's own classpath in this task's classpath?
 void setIncludejavaruntime(boolean include)
          Sets whether or not to include the java runtime libraries to this task's classpath.
 void setMemoryInitialSize(java.lang.String memoryInitialSize)
          Set the memoryInitialSize flag.
 void setMemoryMaximumSize(java.lang.String memoryMaximumSize)
          Set the memoryMaximumSize flag.
 void setNowarn(boolean flag)
          Sets whether the -nowarn option should be used.
 void setOptimize(boolean optimize)
          Set the optimize flag.
 void setProceed(boolean proceed)
          Proceed if compilation fails
 void setSource(java.lang.String v)
          Set the value of source.
 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, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, setDefaultexcludes, setExcludes, setExcludesfile, setIncludes, setIncludesfile, XsetIgnore, XsetItems
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, init, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

failOnError

protected boolean failOnError

compileList

protected java.io.File[] compileList
Constructor Detail

Javac

public Javac()
Method Detail

getSource

public java.lang.String getSource()
Get the value of source.
Returns:
value of source.

setSource

public void setSource(java.lang.String v)
Set the value of source.
Parameters:
v - Value to assign to source.

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.

getSrcdir

public Path getSrcdir()
Gets 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.

getDestdir

public java.io.File getDestdir()
Gets 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.

getClasspath

public Path getClasspath()
Gets 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.

getBootclasspath

public Path getBootclasspath()
Gets 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.

getExtdirs

public Path getExtdirs()
Gets the extension directories that will be used during the compilation.

createExtdirs

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

setFailonerror

public void setFailonerror(boolean fail)
Throw a BuildException if compilation fails

setProceed

public void setProceed(boolean proceed)
Proceed if compilation fails

getFailonerror

public boolean getFailonerror()
Gets the failonerror flag.

setDeprecation

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

getDeprecation

public boolean getDeprecation()
Gets the deprecation flag.

setMemoryInitialSize

public void setMemoryInitialSize(java.lang.String memoryInitialSize)
Set the memoryInitialSize flag.

getMemoryInitialSize

public java.lang.String getMemoryInitialSize()
Gets the memoryInitialSize flag.

setMemoryMaximumSize

public void setMemoryMaximumSize(java.lang.String memoryMaximumSize)
Set the memoryMaximumSize flag.

getMemoryMaximumSize

public java.lang.String getMemoryMaximumSize()
Gets the memoryMaximumSize flag.

setEncoding

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

getEncoding

public java.lang.String getEncoding()
Gets the java source file encoding name.

setDebug

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

getDebug

public boolean getDebug()
Gets the debug flag.

setOptimize

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

getOptimize

public boolean getOptimize()
Gets the optimize flag.

setDepend

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

getDepend

public boolean getDepend()
Gets the depend flag.

setVerbose

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

getVerbose

public boolean getVerbose()
Gets 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".

getTarget

public java.lang.String getTarget()
Gets the target VM that the classes will be compiled for.

setIncludeantruntime

public void setIncludeantruntime(boolean include)
Include ant's own classpath in this task's classpath?

getIncludeantruntime

public boolean getIncludeantruntime()
Gets whether or not the ant classpath is to be included in the task's classpath.

setIncludejavaruntime

public void setIncludejavaruntime(boolean include)
Sets whether or not to include the java runtime libraries to this task's classpath.

getIncludejavaruntime

public boolean getIncludejavaruntime()
Gets whether or not the java runtime should be included in this task's classpath.

setFork

public void setFork(boolean fork)
Sets whether to fork the javac compiler.

isForkedJavac

public boolean isForkedJavac()
Is this a forked invocation of JDK's javac?

setNowarn

public void setNowarn(boolean flag)
Sets whether the -nowarn option should be used.

getNowarn

public boolean getNowarn()
Should the -nowarn option be used.

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

getFileList

public java.io.File[] getFileList()
Gets the list of files to be compiled.

isJdkCompiler

protected boolean isJdkCompiler(java.lang.String compiler)


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.