Home | Forums

Installation Options

In order to use Clover with Ant you must put clover.jar in Ant's classpath. Options for doing this depend on the version of Ant you are using.

Ant 1.4.1, 1.5.x

Prior to Ant 1.6, the easiest way to install Clover is to copy clover.jar into ANT_HOME/lib (Since all jars in this directory are automatically added to Ant's classpath by the scripts that start Ant).

Alternatively, you can add CLOVER_HOME/clover.jar to the CLASSPATH system environment variable before running Ant. For information about setting this variable, please consult your Operating System documentation.

Ant 1.6.x

Ant 1.6 introduces several new ways to add jars to Ant's classpath. This allows more flexibility when installing Clover.

Installing Clover locally for a single user

  1. create a directory ${user.home}/.ant/lib
  2. copy clover.jar to ${user.home}/.ant/lib
Note
The location of ${user.home} depends on your JVM and platform. On Unix systems ${user.home} usually maps to the user's home directory. On Windows systems ${user.home} will map to something like C:\Documents and Settings\username\. Check your JVM documentation for more details.

Installing Clover at an arbitary location

You can install Clover at an arbitary location and then refer to it using the -lib command line option with Ant:

 ant -lib CLOVER_HOME/lib buildWithClover

(Where CLOVER_HOME is the directory where Clover was installed).

Adding Clover to Ant's classpath from build.xml

In some cases it is not desirable to add clover.jar to Ant's classpath using the methods described above. This section outlines a method for adding clover.jar to Ant's classpath by modifying only the project build.xml file, using a special utility Ant task called <extendclasspath> that is distributed with Clover.

The <extendclasspath> task is distributed in CLOVER_HOME/etc/cenquatasks.jar

  1. copy CLOVER_HOME/lib/clover.jar and CLOVER_HOME/etc/cenquatasks.jar to a project-relative directory (the rest of these instructions assume both jars are installed at PROJECT_HOME/lib)
  2. edit build.xml and add the following near the top of the file:

You can now use the standard Clover Ant tasks in your build.xml file.

Checking if Clover is available for the build

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.cenqua.clover.CloverInstr" />
 </target>
 <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>
 <target name="with.clover" depends="guard.noclover">
     ...