org.apache.tools.ant.taskdefs

Class Apt

public class Apt extends Javac

Apt Task for running the Annotation processing tool for JDK 1.5. It derives from the existing Javac task, and forces the compiler based on whether we're executing internally, or externally.

Since: Ant 1.7

Nested Class Summary
static classApt.Option
The nested option element.
Field Summary
static StringERROR_IGNORING_COMPILER_OPTION
An warning message when ignoring compiler attribute.
static StringERROR_WRONG_JAVA_VERSION
A warning message if used with java < 1.5.
static StringEXECUTABLE_NAME
The name of the apt tool.
static StringWARNING_IGNORING_FORK
exposed for debug messages
Constructor Summary
Apt()
Construtor for Apt task.
Method Summary
PathcreateFactoryPath()
Add a path to the factoryPath attribute.
Apt.OptioncreateOption()
Create a nested option.
voidexecute()
Do the compilation.
StringgetAptExecutable()
Get the name of the apt executable.
StringgetCompiler()
Get the compiler class name.
StringgetFactory()
Get the factory option for the apt compiler.
PathgetFactoryPath()
Get the factory path attribute.
VectorgetOptions()
Get the options to the compiler.
FilegetPreprocessDir()
Get the preprocessdir attribute.
booleanisCompile()
Get the compile option for the apt compiler.
voidsetCompile(boolean compile)
Set the compile option for the apt compiler.
voidsetCompiler(String compiler)
Set the compiler.
voidsetFactory(String factory)
Set the factory option for the apt compiler.
voidsetFactoryPathRef(Reference ref)
Add a reference to a path to the factoryPath attribute.
voidsetFork(boolean fork)
Set the fork attribute.
voidsetPreprocessDir(File preprocessDir)
Set the preprocessdir attribute.

Field Detail

ERROR_IGNORING_COMPILER_OPTION

public static final String ERROR_IGNORING_COMPILER_OPTION
An warning message when ignoring compiler attribute.

ERROR_WRONG_JAVA_VERSION

public static final String ERROR_WRONG_JAVA_VERSION
A warning message if used with java < 1.5.

EXECUTABLE_NAME

public static final String EXECUTABLE_NAME
The name of the apt tool.

WARNING_IGNORING_FORK

public static final String WARNING_IGNORING_FORK
exposed for debug messages

Constructor Detail

Apt

public Apt()
Construtor for Apt task. This sets the apt compiler adapter as the compiler in the super class.

Method Detail

createFactoryPath

public Path createFactoryPath()
Add a path to the factoryPath attribute.

Returns: a path to be configured.

createOption

public Apt.Option createOption()
Create a nested option.

Returns: an option to be configured.

execute

public void execute()
Do the compilation.

Throws: BuildException on error.

getAptExecutable

public String getAptExecutable()
Get the name of the apt executable.

Returns: the name of the executable.

getCompiler

public String getCompiler()
Get the compiler class name.

Returns: the compiler class name.

getFactory

public String getFactory()
Get the factory option for the apt compiler. If this is non-null the "-factory" argument will be used.

Returns: the value of the factory option.

getFactoryPath

public Path getFactoryPath()
Get the factory path attribute. If this is not null, the "-factorypath" argument will be used. The default value is null.

Returns: the factory path attribute.

getOptions

public Vector getOptions()
Get the options to the compiler. Each option will use '"-E" name ["=" value]' argument.

Returns: the options.

getPreprocessDir

public File getPreprocessDir()
Get the preprocessdir attribute. This corresponds to the "-s" argument. The default value is null.

Returns: the preprocessdir attribute.

isCompile

public boolean isCompile()
Get the compile option for the apt compiler. If this is false the "-nocompile" argument will be used.

Returns: the value of the compile option.

setCompile

public void setCompile(boolean compile)
Set the compile option for the apt compiler. Default value is true.

Parameters: compile if true set the compile option.

setCompiler

public void setCompiler(String compiler)
Set the compiler. This is not allowed and a warning log message is made.

Parameters: compiler not used.

setFactory

public void setFactory(String factory)
Set the factory option for the apt compiler. Default value is null.

Parameters: factory the classname of the factory.

setFactoryPathRef

public void setFactoryPathRef(Reference ref)
Add a reference to a path to the factoryPath attribute.

Parameters: ref a reference to a path.

setFork

public void setFork(boolean fork)
Set the fork attribute. Non-forking APT is highly classpath dependent and appears to be too brittle to work. The sole reason this attribute is retained is the superclass does it

Parameters: fork if false; warn the option is ignored.

setPreprocessDir

public void setPreprocessDir(File preprocessDir)
Set the preprocessdir attribute.

Parameters: preprocessDir where to place processor generated source files.