Browse Source

Apt docs. Also flipped the nocompile flag in name and meaning

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276939 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 20 years ago
parent
commit
00a70173b2
5 changed files with 159 additions and 6 deletions
  1. +146
    -0
      docs/manual/CoreTasks/apt.html
  2. +1
    -0
      docs/manual/coretasklist.html
  3. +6
    -0
      docs/manual/tasksoverview.html
  4. +5
    -5
      src/main/org/apache/tools/ant/taskdefs/Apt.java
  5. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java

+ 146
- 0
docs/manual/CoreTasks/apt.html View File

@@ -0,0 +1,146 @@
<html lang="en-us"><head>
<meta http-equiv="Content-Language" content="en-us"><title>Apt Task</title></head>

<body>

<h2><a name="Apt">Apt</a></h2>
<h3>Description</h3>
<p>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</p>


<p>This task inherits from the <a href="javac.html">Javac Task</a>, and thus
supports all of the same attributes, and subelements. In addition, it supports
the following addition items:</p>

<h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0">
<tbody><tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">compile</td>
<td valign="top">After running the Apt, should the code be compiled. (see the
"-nocompile" flag on the Apt executable)</td>
<td align="center" valign="top">No, defaults to false.</td>
</tr>
<tr>
<td valign="top">factory</td>
<td valign="top">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.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">factorypathref</td>
<td valign="top">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.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">preprocessdir</td>
<td valign="top">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.</td>
<td align="center" valign="top">No</td>
</tr>
</tbody></table>

<h3>Parameters specified as nested elements</h3>


<h4>factorypath</h4>

<p>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.</p>


<h4>option</h4>

<p>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 &lt;option&gt; elements.</p>

<table border="1" cellpadding="2" cellspacing="0">
<tbody><tr>
<td valign="top" width="12%"><b>Attribute</b></td>
<td valign="top" width="78%"><b>Description</b></td>
<td valign="top" width="10%"><b>Required</b></td>
</tr>
<tr>
<td valign="top">name</td>
<td align="center">The name of the option</td>
<td align="center">Yes.</td>
</tr>
<tr>
<td valign="top">value</td>
<td align="center">The value to set the option to</td>
<td align="center">Yes.</td>
</tr>
</tbody></table>

<h3>Examples</h3>
<pre> &lt;apt srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="on"
compile="true"
factory="com.mycom.MyAnnotationProcessorFactory"
factorypathref="my.factorypath.id"
preprocessdir="${preprocess.dir}"&gt;
&lt;/apt&gt;</pre>
<p>compiles all <code>.java</code> files under the <code>${src}</code>
directory, and stores
the <code>.class</code> files in the <code>${build}</code> directory.
The classpath used includes <code>xyz.jar</code>, 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
<code>${preprocess.dir}</code> directory, using the class
<code>com.mycom.MyAnnotationProcessorFactory</code> to supply
AnnotationProcessor instances.</p>


<h3>Notes</h3>
<p>
The "compiler" attribute is ignored, as it is forced to use the Apt compiler
</p>

<p>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
<code>&lt;javac&gt;</code> task to compile first your original source code, and then the
generated source code:</p>

<pre> &lt;Apt srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="true"
compile="false"
factory="com.mycom.MyAnnotationProcessorFactory"
factorypathref="my.factorypath.id"
preprocessdir="${preprocess.dir}"&gt;
&lt;/apt&gt;

&lt;javac srcdir="${src}"
destdir="${build}"
classpath="xyz.jar"
debug="on" /&gt;

&lt;javac srcdir="${preprocess.dir}"
destdir="${build}"
classpath="xyz.jar"
debug="true" /&gt;
</pre>

This may involve more build file coding, but the speedup gained from switching
to jikes may justify the effort.
<p>
</p><hr>
<p align="center">Copyright © 2004 The Apache Software Foundation.
All rights Reserved.</p>

</body></html>

+ 1
- 0
docs/manual/coretasklist.html View File

@@ -19,6 +19,7 @@
<a href="CoreTasks/antcall.html">AntCall</a><br> <a href="CoreTasks/antcall.html">AntCall</a><br>
<a href="CoreTasks/antstructure.html">AntStructure</a><br> <a href="CoreTasks/antstructure.html">AntStructure</a><br>
<a href="CoreTasks/apply.html">Apply/<i>ExecOn</i></a><br> <a href="CoreTasks/apply.html">Apply/<i>ExecOn</i></a><br>
<a href="CoreTasks/apt.html">Apt</a><br>
<a href="CoreTasks/available.html">Available</a><br> <a href="CoreTasks/available.html">Available</a><br>
<a href="CoreTasks/basename.html">Basename</a><br> <a href="CoreTasks/basename.html">Basename</a><br>
<a href="CoreTasks/buildnumber.html">BuildNumber</a><br> <a href="CoreTasks/buildnumber.html">BuildNumber</a><br>


+ 6
- 0
docs/manual/tasksoverview.html View File

@@ -238,6 +238,12 @@ documentation.</p>
specified.</p></td> specified.</p></td>
</tr> </tr>


<tr valign="top">
<td nowrap><a href="CoreTasks/apt.html">Apt</a></td>
<td><p>Runs the annotation processor tool (apt), and then optionally compiles
the original code, and any generated source code.</p></td>
</tr>

<tr valign="top"> <tr valign="top">
<td nowrap><a href="OptionalTasks/jspc.html">JspC</a></td> <td nowrap><a href="OptionalTasks/jspc.html">JspC</a></td>
<td><p>Runs the JSP compiler. It can be used to precompile JSP pages <td><p>Runs the JSP compiler. It can be used to precompile JSP pages


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

@@ -38,7 +38,7 @@ import java.io.File;


public class Apt public class Apt
extends Javac { extends Javac {
private boolean noCompile;
private boolean compile=true;
private String factory; private String factory;
private Path factoryPath; private Path factoryPath;
private Vector options; private Vector options;
@@ -101,12 +101,12 @@ public class Apt
return super.getCompiler(); 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() { public String getFactory() {


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/AptCompilerAdapter.java View File

@@ -49,7 +49,7 @@ public class AptCompilerAdapter extends DefaultCompilerAdapter {


static void setAptCommandlineSwitches(Apt apt, Commandline cmd) { static void setAptCommandlineSwitches(Apt apt, Commandline cmd) {


if (apt.isNoCompile()) {
if (!apt.isCompile()) {
cmd.createArgument().setValue("-nocompile"); cmd.createArgument().setValue("-nocompile");
} }




Loading…
Cancel
Save