Clover-for-Ant Two Line Integration

To get Clover integrated into your build as quickly as possible, follow these simple steps.

  1. Install Clover-for-Ant in Ant classpath.
  2. Import Clover targets in your build.xml file:

    <taskdef resource="cloverlib.xml"/>

    (info) Note that this will not work within an Ant target. It must be at the top level of the build file.

  3. Add the clover.jar to your test classpath:

    <junit fork="true" forkmode="once">
        <pathelement location="${user.home}/.ant/lib/clover.jar"/>
  4. If you have a target already called "test" you can simply run

    ant clover.all

    Otherwise, run the following:

    ant with.clover

    Alternatively, define a property called "" whose value is the name of your test target.

  5. Complete! That concludes the Ant two-line integration. You should now be set up to run Clover on your Ant builds and start taking advantage of Clover's advanced code coverage analysis.




By calling <clover-env/>, the following targets becomes available to you:

Target Name


clover.all Runs clover.clean, with.clover, test, from a single target.

Deletes the clover database and the




Generates an HTML and XML report to





Same as clover.current, however a history report will also be created, using the historypoints in



Saves a history point to

with.clover Enables Clover on this build
clover.snapshot Saves a snapshot file to assist with unit test optimization

(info) These are available also by running `ant -projecthelp`.


For more instructions about using targets, see the Clover Target Reference. Any ${} properties may be defined on the command line, for example: