FileDocCategorySizeDatePackage
Apt.javaAPI DocApache Ant 1.707381Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs

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

Fields Summary
private boolean
compile
private String
factory
private org.apache.tools.ant.types.Path
factoryPath
private Vector
options
private File
preprocessDir
public static final String
EXECUTABLE_NAME
The name of the apt tool.
public static final String
ERROR_IGNORING_COMPILER_OPTION
An warning message when ignoring compiler attribute.
public static final String
ERROR_WRONG_JAVA_VERSION
A warning message if used with java < 1.5.
public static final String
WARNING_IGNORING_FORK
exposed for debug messages
Constructors Summary
public Apt()
Construtor for Apt task. This sets the apt compiler adapter as the compiler in the super class.

        super();
        super.setCompiler(AptExternalCompilerAdapter.class.getName());
        setFork(true);
    
Methods Summary
public org.apache.tools.ant.types.PathcreateFactoryPath()
Add a path to the factoryPath attribute.

return
a path to be configured.

        if (factoryPath == null) {
            factoryPath = new Path(getProject());
        }
        return factoryPath.createPath();
    
public org.apache.tools.ant.taskdefs.Apt$OptioncreateOption()
Create a nested option.

return
an option to be configured.

        Option opt = new Option();
        options.add(opt);
        return opt;
    
public voidexecute()
Do the compilation.

throws
BuildException on error.

        super.execute();
    
public java.lang.StringgetAptExecutable()
Get the name of the apt executable.

return
the name of the executable.

        return JavaEnvUtils.getJdkExecutable(EXECUTABLE_NAME);
    
public java.lang.StringgetCompiler()
Get the compiler class name.

return
the compiler class name.

        return super.getCompiler();
    
public java.lang.StringgetFactory()
Get the factory option for the apt compiler. If this is non-null the "-factory" argument will be used.

return
the value of the factory option.

        return factory;
    
public org.apache.tools.ant.types.PathgetFactoryPath()
Get the factory path attribute. If this is not null, the "-factorypath" argument will be used. The default value is null.

return
the factory path attribute.

        return factoryPath;
    
public java.util.VectorgetOptions()
Get the options to the compiler. Each option will use '"-E" name ["=" value]' argument.

return
the options.

        return options;
    
public java.io.FilegetPreprocessDir()
Get the preprocessdir attribute. This corresponds to the "-s" argument. The default value is null.

return
the preprocessdir attribute.

        return preprocessDir;
    
public booleanisCompile()
Get the compile option for the apt compiler. If this is false the "-nocompile" argument will be used.

return
the value of the compile option.

        return compile;
    
public voidsetCompile(boolean compile)
Set the compile option for the apt compiler. Default value is true.

param
compile if true set the compile option.

        this.compile = compile;
    
public voidsetCompiler(java.lang.String compiler)
Set the compiler. This is not allowed and a warning log message is made.

param
compiler not used.

        log(ERROR_IGNORING_COMPILER_OPTION, Project.MSG_WARN);
    
public voidsetFactory(java.lang.String factory)
Set the factory option for the apt compiler. Default value is null.

param
factory the classname of the factory.

        this.factory = factory;
    
public voidsetFactoryPathRef(org.apache.tools.ant.types.Reference ref)
Add a reference to a path to the factoryPath attribute.

param
ref a reference to a path.

        createFactoryPath().setRefid(ref);
    
public voidsetFork(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

param
fork if false; warn the option is ignored.

        if (!fork) {
            log(WARNING_IGNORING_FORK, Project.MSG_WARN);
        }
    
public voidsetPreprocessDir(java.io.File preprocessDir)
Set the preprocessdir attribute.

param
preprocessDir where to place processor generated source files.

        this.preprocessDir = preprocessDir;