Browse Source

javadoc

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277398 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
bd97537227
1 changed files with 107 additions and 5 deletions
  1. +107
    -5
      src/main/org/apache/tools/ant/taskdefs/Apt.java

+ 107
- 5
src/main/org/apache/tools/ant/taskdefs/Apt.java View File

@@ -41,54 +41,95 @@ public class Apt
private boolean compile = true; private boolean compile = true;
private String factory; private String factory;
private Path factoryPath; private Path factoryPath;
private Vector options;
private Vector options = new Vector();
private File preprocessDir; private File preprocessDir;
/** The name of the apt tool. */
public static final String EXECUTABLE_NAME = "apt"; public static final String EXECUTABLE_NAME = "apt";
public static final String ERROR_IGNORING_COMPILER_OPTION = "Ignoring compiler attribute for the APT task, as it is fixed";
public static final String ERROR_WRONG_JAVA_VERSION = "Apt task requires Java 1.5+";
/** An warning message when ignoring compiler attribute. */
public static final String ERROR_IGNORING_COMPILER_OPTION
= "Ignoring compiler attribute for the APT task, as it is fixed";
/** A warning message if used with java < 1.5. */
public static final String ERROR_WRONG_JAVA_VERSION
= "Apt task requires Java 1.5+";


/** /**
* option element
* The nested option element.
*/ */
public static final class Option { public static final class Option {
private String name; private String name;
private String value; private String value;


/** Constructor for Option */
public Option() { public Option() {
} }


/**
* Get the name attribute.
* @return the name attribute.
*/
public String getName() { public String getName() {
return name; return name;
} }


/**
* Set the name attribute.
* @param name the name of the option.
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }


/**
* Get the value attribute.
* @return the value attribute.
*/
public String getValue() { public String getValue() {
return value; return value;
} }


/**
* Set the value attribute.
* @param value the value of the option.
*/
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
} }


/**
* Construtor for Apt task.
* This sets the apt compiler adapter as the compiler in the super class.
*/
public Apt() { public Apt() {
super(); super();
super.setCompiler(AptCompilerAdapter.class.getName()); super.setCompiler(AptCompilerAdapter.class.getName());
this.options = new Vector();
} }


/**
* Get the name of the apt executable.
*
* @return the name of the executable.
*/
public String getAptExecutable() { public String getAptExecutable() {
return JavaEnvUtils.getJdkExecutable(EXECUTABLE_NAME); return JavaEnvUtils.getJdkExecutable(EXECUTABLE_NAME);
} }


/**
* Set the compiler.
* This is not allowed and a warning log message is made.
* @param compiler not used.
*/
public void setCompiler(String compiler) { public void setCompiler(String compiler) {
log(ERROR_IGNORING_COMPILER_OPTION, log(ERROR_IGNORING_COMPILER_OPTION,
Project.MSG_WARN); Project.MSG_WARN);
} }


/**
* Set the fork attribute.
* If fork is true run the external apt command.
* If fork is false run the apt compiler in the same jvm as the task.
* @param fork if true use the external command.
*/
public void setFork(boolean fork) { public void setFork(boolean fork) {
if (fork) { if (fork) {
super.setCompiler(AptExternalCompilerAdapter.class.getName()); super.setCompiler(AptExternalCompilerAdapter.class.getName());
@@ -97,30 +138,62 @@ public class Apt
} }
} }


/**
* Get the compiler class name.
* @return the compiler class name.
*/
public String getCompiler() { public String getCompiler() {
return super.getCompiler(); return super.getCompiler();
} }


/**
* 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.
*/
public boolean isCompile() { public boolean isCompile() {
return compile; return compile;
} }


/**
* Set the compile option for the apt compiler.
* Default value is true.
* @param compile if true set the compile option.
*/
public void setCompile(boolean compile) { public void setCompile(boolean compile) {
this.compile = compile; this.compile = compile;
} }


/**
* 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.
*/
public String getFactory() { public String getFactory() {
return factory; return factory;
} }


/**
* Set the factory option for the apt compiler.
* Default value is null.
* @param factory the classname of the factory.
*/
public void setFactory(String factory) { public void setFactory(String factory) {
this.factory = factory; this.factory = factory;
} }


/**
* Add a reference to a path to the factoryPath attribute.
* @param ref a reference to a path.
*/
public void setFactoryPathRef(Reference ref) { public void setFactoryPathRef(Reference ref) {
createFactoryPath().setRefid(ref); createFactoryPath().setRefid(ref);
} }


/**
* Add a path to the factoryPath attribute.
* @return a path to be configured.
*/
public Path createFactoryPath() { public Path createFactoryPath() {
if (factoryPath == null) { if (factoryPath == null) {
factoryPath = new Path(getProject()); factoryPath = new Path(getProject());
@@ -128,28 +201,57 @@ public class Apt
return factoryPath.createPath(); return factoryPath.createPath();
} }


/**
* 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.
*/
public Path getFactoryPath() { public Path getFactoryPath() {
return factoryPath; return factoryPath;
} }


/**
* Create a nested option.
* @return an option to be configured.
*/
public Option createOption() { public Option createOption() {
Option opt = new Option(); Option opt = new Option();
options.add(opt); options.add(opt);
return opt; return opt;
} }


/**
* Get the options to the compiler.
* Each option will use '"-E" name ["=" value]' argument.
* @return the options.
*/
public Vector getOptions() { public Vector getOptions() {
return options; return options;
} }


/**
* Get the preprocessdir attribute.
* This corresponds to the "-s" argument.
* The default value is null.
* @return the preprocessdir attribute.
*/
public File getPreprocessDir() { public File getPreprocessDir() {
return preprocessDir; return preprocessDir;
} }


/**
* Set the preprocessdir attribute.
* @param preprocessDir where to place processor generated source files.
*/
public void setPreprocessDir(File preprocessDir) { public void setPreprocessDir(File preprocessDir) {
this.preprocessDir = preprocessDir; this.preprocessDir = preprocessDir;
} }


/**
* Do the compilation.
* @throws BuildException on error.
*/
public void execute() public void execute()
throws BuildException { throws BuildException {
if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) { if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_5)) {


Loading…
Cancel
Save