The dashboard plugin supports custom aggregators. This page is a tutorial explaining how to create a custom aggregator.
An aggregator is a Jelly script that you plug in the dashboard plugin. This Jelly script is called on each Maven subproject to extract a single piece of data (ex: number of checkstyle errors, Clover test coverage percentage, etc).
The Jelly script must output the aggregator data for a project. For example:
<?xml version="1.0"?> <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:u="jelly:util"> <u:file var="artifactAsFile" name="${maven.dashboard.aggregator.cserrors.artifact}"/> <j:choose> <j:when test="${artifactAsFile.exists()}"> <x:parse var="doc" xml="${artifactAsFile}"/> <x:expr select="count($doc//error[@severity = 'error'])"/> </j:when> <j:otherwise> <j:expr value="-"/> </j:otherwise> </j:choose> </j:jelly>
Note that the Jelly script has access to all of the Dashboard plugin properties.
Add the following properties to your master project's
project.properties
:
# Properties for my custom aggregator maven.dashboard.aggregator.[aggregator name].script = [location of my custom jelly script] maven.dashboard.aggregator.[aggregator name].artifact = [Location of artifacts from which to extract data] maven.dashboard.aggregator.[aggregator name].label = [Label to display in report] maven.dashboard.aggregator.[aggregator name].goal = [Goal to call that generates the artifact above] maven.dashboard.aggregator.[aggregator name].description = [Aggregator description legend]
In order to use your aggregator in the dashboard report, you need to
add it to the list of aggregators by adding the following property in
your project.properties
:
maven.dashboard.aggregators = [aggregator name],[other aggregators to use]
If there is no existing goal that generates the data you need, create
a custom goal in your top level maven.xml
. Make sure your
subprojects inherit from this top level project (so that
maven.xml
is inherited).
If you think your aggregator could be useful to others, feel free to donate it to the Maven project.