Creating custom reports

Configuring reports

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

It is possible to define an external clover report descriptor file, the same way one can define a site.xml descriptor file. The descriptor file is basically a stripped down Ant file which will be run to produce the reports. All options available in clover-report can be specified. The default report descriptor used by the clover-maven-plugin is:

<project name="Clover Report" default="current">

    <clover-format id="clover.format" type="${type}" orderBy="${orderBy}" filter="${filter}"/>
    <clover-setup initString="${cloverdb}"/>

    <clover-columns id="clover.columns">
        <totalChildren/>
        <avgMethodComplexity/>
        <uncoveredElements format="raw"/>
        <totalPercentageCovered format="longbar"/>
    </clover-columns>


    <target name="historical">
        <clover-report>
            <current outfile="${output}"  summary="${summary}">
                <format refid="clover.format"/>
                <testsources dir="${tests}"/>
                <columns refid="clover.columns"/>
            </current>
            <historical outfile="${historyout}" historydir="${history}">
                <format refid="clover.format"/>
                <columns refid="clover.columns"/>
            </historical>
        </clover-report>
    </target>

    <target name="current">
        <clover-report>
            <current outfile="${output}" title="${title}" summary="${summary}">
                <format refid="clover.format"/>
                <testsources dir="${tests}"/>
                <columns refid="clover.columns"/>
            </current>
        </clover-report>
    </target>

</project>

This is a very simple Ant file, which defines two known targets: "historical" and "current" .
If there are no history points saved (via: clover:save-history) then only the "current" target will be called. Otherwise, the "historical" target gets called which generates both a historical and current report which are linked together.

To change Clover's default reporting behavior, it is easiest to copy this file and add the changes you require. For a full list of clover-report elements and attributes, please consult the clover-report documentation.

This file can be stored either on your local file system, or in your maven repository as a classified artifact.

If stored on the file system, set this system property:

-Dmaven.clover.reportDescriptor=/path/to/clover-report.xml

or specify this element:

<reportDescriptor>/path/to/clover-report.xml</reportDescriptor>

in the <configuration> element for the clover-maven-plugin in your pom.xml.

If you wish to keep this descriptor in your maven repository you must specify this system property:

-Dmaven.clover.resolveReportDescriptor=true

or set this element:

<resolveReportDescriptor>true</resolveReportDescriptor>

in the <configuration> element for the clover-maven-plugin in your pom.xml.
The descriptor should be deployed using the "clover-report" classifier. For example:

mvn deploy:deploy-file -DgroupId=my.group.id -DartifactId=my-artifact-id -Dversion=X.X -Dclassifier=clover-report \
 -Dpackaging=xml -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Properties for Custom Reports

Standard Maven properties

A custom clover report descriptor can access the standard Maven 2 and 3 properties. The following properties are available:

  • project.url
  • project.version
  • project.name
  • project.description
  • project.id
  • project.groupId
  • project.inceptionYear

In addition to these properties, any additional properties defined in pom.xml will also be available.

Clover configuration properties

Configuration options defined for clover:clover MOJO are available in report descriptor under following names:

  • ${cloverdb} = full path to Clover database, depending on settings:
    • default database location (<build directory>/clover/clover.db) or
    • maven.clover.cloverDatabase or 
    • maven.clover.cloverMergeDatabase
  • ${output} = full path to report directory or file:
    • absolute path of maven.clover.outputDirectory (HTML/JSON reports) or
    • maven.clover.outputDirectory + "/clover.pdf" (PDF report) or
    • maven.clover.outputDirectory + "/clover.xml" (XML report)
  • ${history} = maven.clover.historyDir
  • ${title} = report title, one of:
    • maven.clover.title or 
    • project's artifactId + version
    • in case when maven.clover.cloverMergeDatabase is set then the "(Aggregated)" word is appended
  • ${titleAnchor} = maven.clover.titleAnchor
  • ${projectDir} = project base dir
  • ${testPattern} = "**/src/test/**"
  • ${filter} = maven.clover.contextFilters
  • ${orderBy} = maven.clover.orderBy
  • ${charset} = maven.clover.charset
  • ${type} = html / pdf / xml / json 
    • depends on maven.clover.generateHtml / maven.clover.generatePdf / maven.clover.generateXml / maven.clover.generateJson
    • custom report will be run for each of types enabled
  • ${reportStyle} = style of the report ("adg" / "classic") - since Clover 4.0
  • ${span} = maven.clover.span
  • ${alwaysReport} = maven.clover.alwaysReport
  • ${summary} = whether to generate a summary, true for PDF report
  • ${historyout} = location of history report
    • ${output} for HTML
    • ${output}/historical.pdf for PDF

 

Last modified on Dec 8, 2015

Was this helpful?

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