diff --git a/docs/manual/CoreTasks/apt.html b/docs/manual/CoreTasks/apt.html new file mode 100644 index 000000000..004533a2c --- /dev/null +++ b/docs/manual/CoreTasks/apt.html @@ -0,0 +1,146 @@ +
+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:
+ +| 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 | +
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.
+ +| Attribute | +Description | +Required | +
| name | +The name of the option | +Yes. | +
| value | +The value to set the option to | +Yes. | +
<apt srcdir="${src}"
+ destdir="${build}"
+ classpath="xyz.jar"
+ debug="on"
+ compile="true"
+ factory="com.mycom.MyAnnotationProcessorFactory"
+ factorypathref="my.factorypath.id"
+ preprocessdir="${preprocess.dir}">
+ </apt>
+compiles all .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.
+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
+ <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.
++
Copyright © 2004 The Apache Software Foundation. +All rights Reserved.
+ + \ No newline at end of file diff --git a/docs/manual/coretasklist.html b/docs/manual/coretasklist.html index 1850929ad..de64806dc 100644 --- a/docs/manual/coretasklist.html +++ b/docs/manual/coretasklist.html @@ -19,6 +19,7 @@ AntCallRuns 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"); }