The <clover-log> task reports coverage information to the console at different levels.


Attribute Description Required

The initstring of the coverage database.

No; if not specified here, Clover will use the default location (${basedir}/.clover). If you have specified an initstring on the <clover-setup> task, you must ensure that <clover-setup> is called prior the execution of this task.


Controls the level of detail included in the report. Valid values are summary, class, method, statement

No; defaults to "summary".


comma or space separated list of contexts to ignore when calculating coverage. See Using Coverage Contexts.


Specifies how far back in time to include coverage recordings from since the last Clover build. See Using Spans.

No; defaults includes "all coverage data found".

Since 3.1.6: Specifies which sources shall be taken for calculation. This attribute should be used together with <testSources> nested element.

Valid values are: APPLICATION (business code), TEST (test code), ALL (business + test code).

No; Default value: APPLICATION.
showUnitTests Since 3.1.6: Show unit tests summary in the report. Must be used with codeType=ALL or codeType=TEST. No; Default value: false
outputProperty Since 3.1.6: Name of the Ant property in which a clover-log report will be stored, instead of printing it to console. No;


Nested elements


Specifies an Ant fileset. Only these files will be used when generating the clover-log messages and coverage data.



Specifies a named package to restrict the report to. Multiple <package> elements can be specified.

Attribute Description Required
name The name of the package to include. Yes.



Specifies an Ant path that Clover should use when looking for source files.



Since 3.1.6: Specifies an Ant fileset. These files will be treated as test code (codeType=TEST), all others will be treated as business code (codeType=APPLICATION).




Prints a summary of code coverage to the console.


     <package name="com.acme.killerapp.core"/>

Prints a summary of code coverage for the package com.acme.killerapp.core to the console.


<clover-log level="statement">
     <package name="com.acme.killerapp.core"/>

Prints detailed (source-level) code coverage information for the package com.acme.killerapp.core to the console.


<clover-log level="statement" filter="catch">
     <package name="com.acme.killerapp.core"/>

As above, but catch blocks will not be considered in coverage reporting.


<clover-log level="statement">
       <pathelement path="/some/other/location"/>

Prints source-level coverage report to the console. Clover will look for source files in the directory /some/other/location.


<clover-log codeType="APPLICATION">
    <fileset dir="src/main/java"/>
    <fileset dir="src/main/groovy"/>
    <fileset dir="src/test/java"/>
    <testSources dir="src/test/java"/>

Collect coverage data from three directories: src/main/java, src/main/groovy and src/test/java. Test sources are located in: src/test/java. Report coverage for business code only (codeType = APPLICATION), i.e. skip files from src/test/java.


Sample output

Example for <clover-log showUnitTests="true" code="ALL".../>

Clover Coverage Report
Coverage Timestamp: Tue May 22 13:21:44 CEST 2012
Report for code   : ALL

Coverage Overview -
      Methods: 4/7 (57,1%)
   Statements: 8/14 (57,1%)
     Branches: 0/0 ( - )
        Total: 57,1%
   Avg Method: 1.0
      Density: 0.5
        Total: 7
 Tests number: 2
    Tests run: 2
 Tests passed: 2
 Tests failed: 0
 Tests errors: 0


By default, log output is written in plain text, for instance:

but if you have a terminal supporting ANSI colors (Linux, for example) you can use -Dansi.color=true property to get a report like this: