From 00a70173b29f3778d39c6fdf664624ad739137d5 Mon Sep 17 00:00:00 2001
From: Steve Loughran Runs the annotation processor tool (apt), and then optionally compiles
+ the original code, and any generated source code. This task requires Java1.5 or later This task inherits from the Javac Task, and thus
+ supports all of the same attributes, and subelements. In addition, it supports
+ the following addition items: You can specify the path used to find the classes needed by the AnnotationProcessorFactory
+ at runtime, using this element. It is represents as a generic path like structure. This
+ represents the "-factorypath" flag on the Apt executable. Used to represent a generic option to pass to Apt. This represents the "-A" flag on the
+ Apt executable. You can specify zero or more <option> elements. compiles all
+The "compiler" attribute is ignored, as it is forced to use the Apt compiler
+ Using the Apt compiler with the "compile" option set to "true"
+ forces you to use Sun's Apt compiler, which will use the JDK's Javac compiler.
+ If you wish to use another compiler, you will first need run the Apt processor
+ with the "compile" flag set to "false", and then use a
+
+ Copyright © 2004 The Apache Software Foundation.
+All rights Reserved.Apt
+Description
+Parameters
+
+
+
+
+
+ Attribute
+ Description
+ Required
+
+
+ compile
+ After running the Apt, should the code be compiled. (see the
+ "-nocompile" flag on the Apt executable)
+ No, defaults to false.
+
+
+ factory
+ The fully qualified classname of the AnnotationProcessFactory to be used
+ to construct annotation processors. This represents the "-factory"
+ command line flag of the Apt executable.
+ No
+
+
+ factorypathref
+ The reference id of the path used to find the classes needed by the
+ AnnotationProcessorFactory (and the location of the factory itself).
+ This represents the "-factorypath" flag on the Apt executable.
+ No
+
+
+preprocessdir
+ The directory used for preprocessing. This is the directory where the
+ generated source code will be place. This represents the "-s" flag on
+ the Apt executable.
+ No
+ Parameters specified as nested elements
+
+
+factorypath
+
+option
+
+
+
+
+
+
+ Attribute
+ Description
+ Required
+
+
+ name
+ The name of the option
+ Yes.
+
+
+value
+ The value to set the option to
+ Yes.
+ Examples
+ <apt srcdir="${src}"
+ destdir="${build}"
+ classpath="xyz.jar"
+ debug="on"
+ compile="true"
+ factory="com.mycom.MyAnnotationProcessorFactory"
+ factorypathref="my.factorypath.id"
+ preprocessdir="${preprocess.dir}">
+ </apt>
+.java
files under the ${src}
+directory, and stores
+the .class
files in the ${build}
directory.
+The classpath used includes xyz.jar
, and compiling with
+debug information is on. It also forces the generated source code to
+be compiled. The generated source code will be placed in
+${preprocess.dir}
directory, using the class
+com.mycom.MyAnnotationProcessorFactory
to supply
+AnnotationProcessor instances.Notes
+<javac>
task to compile first your original source code, and then the
+ generated source code: <Apt srcdir="${src}"
+ destdir="${build}"
+ classpath="xyz.jar"
+ debug="true"
+ compile="false"
+ factory="com.mycom.MyAnnotationProcessorFactory"
+ factorypathref="my.factorypath.id"
+ preprocessdir="${preprocess.dir}">
+ </apt>
+
+ <javac srcdir="${src}"
+ destdir="${build}"
+ classpath="xyz.jar"
+ debug="on" />
+
+ <javac srcdir="${preprocess.dir}"
+ destdir="${build}"
+ classpath="xyz.jar"
+ debug="true" />
+
+
+This may involve more build file coding, but the speedup gained from switching
+to jikes may justify the effort.
+
+
AntStructure
Apply/ExecOn
+Apt
Available
Basename
BuildNumber
diff --git a/docs/manual/tasksoverview.html b/docs/manual/tasksoverview.html
index 904dd262f..63937854a 100644
--- a/docs/manual/tasksoverview.html
+++ b/docs/manual/tasksoverview.html
@@ -238,6 +238,12 @@ documentation.
Runs the annotation processor tool (apt), and then optionally compiles + the original code, and any generated source code.
Runs the JSP compiler. It can be used to precompile JSP pages diff --git a/src/main/org/apache/tools/ant/taskdefs/Apt.java b/src/main/org/apache/tools/ant/taskdefs/Apt.java index 0e769250a..535fed8a4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Apt.java +++ b/src/main/org/apache/tools/ant/taskdefs/Apt.java @@ -38,7 +38,7 @@ import java.io.File; public class Apt extends Javac { - private boolean noCompile; + private boolean compile=true; private String factory; private Path factoryPath; private Vector options; @@ -101,12 +101,12 @@ public class Apt return super.getCompiler(); } - public boolean isNoCompile() { - return noCompile; + public boolean isCompile() { + return compile; } - public void setNoCompile(boolean noCompile) { - this.noCompile = noCompile; + public void setCompile(boolean compile) { + this.compile = compile; } public String getFactory() { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java index d21d28d96..5075dd789 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java @@ -49,7 +49,7 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter { static void setAptCommandlineSwitches(Apt apt, Commandline cmd) { - if (apt.isNoCompile()) { + if (!apt.isCompile()) { cmd.createArgument().setValue("-nocompile"); }