The Dashboard Plugin is designed for extension. We provide a simple interface, DashboardReport , that can be implemented to add new statistics to the dashboard table.
To write your own addition to the Dashboard report and use it in your site do the following four steps:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xebia.maven.plugins</groupId>
<artifactId>test-maven-dashboard-report</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>test-maven-dashboard-report Maven Mojo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.xebia.mojo</groupId>
<artifactId>maven-dashboard-plugin</artifactId>
<version>1.0-alpha2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The dependency on maven-dashboard-plugin is necessary for the next step.
package com.xebia.maven.plugins;
import java.util.Collections;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.dom4j.DocumentHelper;
import org.dom4j.Node;
import com.xebia.mojo.dashboard.DashboardReport;
public class TestDashboardReport implements DashboardReport {
public boolean canExecute(MavenProject arg0) {
return true;
}
public Node getContent(MavenProject arg0, String arg1) throws MojoExecutionException {
return DocumentHelper.createText("This is a test");
}
public String getHeaderForColumn(String arg0) {
return null;
}
public String getLinkLocation() {
return null;
}
public List getColumnNames() {
return Collections.singletonList("test");
}
public String title() {
return "Test";
}
}
<build>
...
<plugins>
...
<plugin>
<groupId>com.xebia.mojo</groupId>
<artifactId>maven-dashboard-plugin</artifactId>
<configuration>
...
<reports>
...
<report>com.xebia.maven.plugins.TestDashboardReport</report>
</reports>
...
</configuration>
</plugin>
</plugins>
</build>
Adding your own report makes adding other dashboard reports to the configuration mandatory. Other configuration options, like the columns option will also apply to your own dashboard report. You cannot use an alias for your custom dashboard report.
There are a few useful classes for when you want to extend the Maven Dashboard Plugin.