Adding Reports to the Website
This section builds on the information on project Web sites in Chapter 2 and Chapter 3, and now shows how to integrate project health information.
To start, review the project Web site shown below:
Figure 6-1: The reports generated by Maven
You can see that the navigation on the left contains a number of reports. The Project Info menu lists the standard reports Maven includes with your site by default, unless you choose to disable them. These reports are useful for sharing information with others, and to reference as links in your mailing lists, SCM, issue tracker, and so on. For newcomers to the project, having these standard reports means that those familiar with Maven Web sites will always know where to find the information they need.
The second menu (shown opened in the figure above), Project Reports, is the focus of the rest of this chapter. These reports provide a variety of insights into the quality and vitality of the project.
On a new project, this menu doesn’t appear as there are no reports included. However, adding a new report is easy. For example, you can add the Surefire report to the sample application, by including the following section in
[...] <reporting> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-report-plugin</artifactId> </plugin> </plugins> </reporting> [...] </project>
This adds the report to the top level project, and as a result, it will be inherited by all of the child modules. You can now run the following site task in the
proficio-core directory to regenerate the site.
C:mvnbookproficioproficio-core> mvn site
This can be found in the file target/site/surefire-report.html and is shown in the figure below.
Figure 6-2: The Surefire report
As you may have noticed in the summary, the report shows the test results of the project.
For a quicker turn around, the report can also be run individually using the following standalone goal:
C:mvnbookproficioproficio-core> mvn surefire-report:report
mvn surefire-report:report generates the
surefire-report.html file in
That’s all there is to generating the report! This is possible thanks to key concepts of Maven discussed in Chapter 2: through a declarative project model, Maven knows where the tests and test results are, and due to using convention over configuration, the defaults are sufficient to get started with a useful report.