This section describes some recommended practices when integrating Clover into your Ant build. For a great list of general Ant best practices, see http://www.onjava.com/pub/a/onjava/2003/12/17/ant_bestpractices.html
initstring
attribute on the <clover-setup>
task. Clover 2 makes the initstring
attribute optional. If not supplied, Clover will automatically create a special directory for the Clover coverage database. There are several advantages in letting Clover use the default location. Clover tasks can find the database more easily, and build files become more portable. If left to the default setting, there is no need to have Clover reporting targets depend on the the Clover setup target.
Note
If you want to specify the initstring
explicity, it is strongly recommended that you give Clover its own direct directory, because a Coverage run can result in many files being written to the database.
<clover-clean>
task<clover-clean>
to delete the database so that it will be freshly created for the next build. This is easily achieved by adding the <clover-clean>
task to any existing clean target.<javac>
task<javac>
task<ant>
and <antcall>
fork="true"
is set). Excessive use of <antcall>
can also make a build file less readable, because it can be difficult to trace which properties and references are valid for a given target.
<ant>
and <antcall>
, be aware that you must set inheritrefs
to "true" if you are calling <clover-setup>
in an upper-level project.
<!-- BAD. References wont be passed (References from <clover-setup/> would be lost). --> <target name="all"> <antcall target="clean"> <antcall target="compile"> <antcall target="dist"> <antcall target="test"> </target>
<!-- GOOD --> <target name="all" depends="clean, compile, dist, test"/>
<junit>
task, consider using fork="true" forkmode="once"