Writing an ANT Task

You must have something like this into your build.xml file:
<project name="OwnTaskExample" default="main" basedir=".">
  <!-- task definition -->
  <taskdef name="plantuml" classname="net.sourceforge.plantuml.ant.PlantUmlTask" classpath="plantuml.jar" />

  <!-- process ./src files -->
  <target name="main">
    <plantuml dir="./src" />

The ANT task processes all .c, .h, .cpp, .tex, .html, .htm or .java of the provided directory (./src in this example). It looks for @startuml and generates .png images.

Output Directory

You can also specify a output directory for all generated images, using output tag.
  <!-- Put images in c:/images directory -->
  <target name="main">
    <plantuml dir="./src" output="c:/images" />

Recurse through directories

You can also use ANT standard fileset or filelist.

If you want to process all java file in c:/src and subdirectories, (except files ending by "Test.java"), and generate images into d:/images, you can use:

<target name="main">
  <plantuml output="d:/images" >
    <fileset dir="c:/src">
    <include name="**/*.java" />
    <exclude name="**/*Test.java" />

SVG or EPS Support

You can also use format="svg" or format="eps" in the ant task definition.

  <target name="main">
    <plantuml dir="./src" format="svg" />

Configuration file

You can also provide a configuration file which will be included before each diagram.
  <target name="main">
    <plantuml dir="./src" config=".config.cfg" />

Other parameters

nbthread1Number of thread for processing
graphvizDotPath of the dot executable
formatpngFormat for image generation: xmi, xmi:argo, xmi:start, eps, svg, txt, utxt
verbosefalsetrue for more logs
keepTmpFilesfalsetrue to NOT delete temporary files after processing
configFile config to include before all diagrams
charsetCharset to use when reading files
outputOutput directory for generated images
dirInput directory to process (You can use <fileset>/<filelist> instead)
suggestenginetruefalse to disable the suggest engine when errors in diagrams
failonerrorfalsetrue to fail the build if some syntax error occurs
checkonlyfalsetrue if you want to only check the syntax of files without generating images
overwritefalsetrue if you want overwrite read-only files
enablestatsfalsetrue to enable statistics
htmlstatsfalsetrue to output general statistics in file plantuml-stats.html
xmlstatsfalsetrue to output general statistics in file plantuml-stats.xml
realtimestatsfalsetrue to generate statistics on the fly rather than at the end