Adding to Ant's build.xml

Clover-for-Ant Installation Guide

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

This is the recommended method of installing Clover.


Adding Clover to your build is done by adding the following to your buildfile (e.g. build.xml):

<taskdef resource="cloverlib.xml" classpath="/path/to/clover.jar"/>

(info) '/path/to' is the path to the 'clover.jar' file. Hence, a typical example of the 'classpath' parameter might be classpath="../lib/clover.jar".

Checking if Clover is available for the build (optional)

In some cases you may want to check if Clover is available before executing Clover-related targets. For example, you may need to ship the build file to others who may not have Clover installed. To check Clover's availability you can make use of the standard Ant <available> task:

<target name="-check.clover">
<available property="clover.installed"
classname="com.atlassian.clover.CloverInstr" />

<target name="guard.noclover" depends="-check.clover" unless="clover.installed">
<fail message="The target you are attempting to run requires Clover, which doesn't appear to be installed"/>

<target name="with.clover" depends="guard.noclover">


  • To enable logging of the Clover installation, set the environment variable ANT_OPTS to '-Dclover.debug=true'
  • Run ant with the -debug and -verbose options
  • Certain environments may require the clover.jar to be placed directly on Ant's Classpath. Details are outlined here.
  • To enable logging of Clover at runtime set the environment variable -Dclover.logging.level=debug on the JVM that is running your Clover instrumented code. e.g. the JUnit JVM, the Tomcat JVM.



See Clover for Ant Best Practices

Last modified on Aug 8, 2014

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.