# `annotationProcessing` Ant Task

## `annotationProcessing` Task Overview

An Ant task for the `annotationProcessing` is provided with &jax-ws.product.name;.

## `annotationProcessing` Task Attributes

The attributes and elements supported by the Ant task almost the same as for the javac ant task. With only one restriction: by default jax-ws annotation processor will be used. There several additional attributes for usability improvement:

Attribute | Description | Required
--- | --- | ---
`procOnly` | Control whether annotation processing and compilation is done. Can be `true` or `false`. Default is `false`. | `false`
`sourcedestdir` | Specify where to place processor generated source files. `-s <path>` | `true`

The list of source files to be processed are specified via a nested `<srcdir>` element. That is, a path-like structure. The classpath attribute is a path-like structure and can also be set via nested `<classpath>` elements. Before this task can be used, a `<taskdef>` element needs to be added to the project as given below:

    <taskdef name="annotationProcessing"
            classname="com.sun.tools.ws.ant.AnnotationProcessingTask">
        <classpath refid="jaxws.classpath"/>
    </taskdef>

where `jaxws.classpath` is a reference to a path-like structure, defined elsewhere in the build environment, and contains the list of classes required by the JAX-WS tools.

## `annotationProcessing` Task Examples

    <annotationProcessing
            destdir="${build.classes.home}"
            sourceDestDir="${build.classes.home}"
            srcdir="${basedir}/src"
            includes="*.java"
            sourcepath="${basedir}/src">
        <classpath refid="jaxws.classpath"/>
    </annotationProcessing>

The above example processes the Java source files in the `${basedir}/src` directory and generates the source and class files in `${build.classes.home}`. `${basedir}/src` is directory used to search for source files for multiple `annotationProcessing` rounds. The classpath is a reference to a path-like structure `jaxws.classpath`, defined elsewhere in the build environment.

    <annotationProcessing
            debug="true"
            verbose="true"
            destdir="${build.classes.home}"
            srcdir="${basedir}/src""
            includes="**/server/*.java"
            sourceDestDir="${build.classes.home}"
            sourcepath="${basedir}/src">
        <classpath refid="jaxws.classpath"/>
    </annotationProcessing>

The above example processes the Java source files in `${basedir}/src/**/server`, generates the source and class files in `${build.classes.home}`, compiles with debug information on, prints a message about what the compiler is doing. `${basedir}/src` is the directory used to search for source files for multiple `annotationProcessing` rounds. The classpath is a reference to a path-like structure `jaxws.classpath`, defined elsewhere in the build environment. This will also fork off the `annotationProcessing` process using the default `java` executable.

## `Apt` Ant task

For backwards compatibility `Apt` Ant task still exists, but is marked as deprecated, and can be used with certain restrictions.