Maven Site Generation¶
In case you already have succeeded migrating your build process to Maven, it is possible that you want to get the most out of it. In this page, the usage of Maven 3 site generation is presented. Site generation includes, not only generating javadocs and documentation, but also reports like those that can be generated by Checkstyle, PMD or FindBugs. Maven has pugins for all of these tools that help developers improve the quality of their software.
In Maven 3, site generation has changed with respect to Maven 2. The reports are now specified within the configuration of the maven-site-plugin. Here is an example of such configuration, from the pascaline parent POM:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-3</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<report>dependencies</report>
<report>dependency-management</report>
<report>project-team</report>
<report>scm</report>
<report>summary</report>
<report>plugin-management</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.4.3</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<goal>aggregate</goal>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<targetJdk>1.6</targetJdk>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
...
</build>
This configuration works perfectly in my laptop. Just issuing mvn site produce a site containing the reports from the tools, and the javadoc for the sources of the project. However, when trying to build the site in Jenkins, the process seems to get stalled when trying to archive the parent site.
References¶
- http://maven.apache.org/plugins/maven-site-plugin-3.0-beta-3/maven-3.html
- https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+and+site+plugin
- https://cwiki.apache.org/MAVEN/maven-3x-and-site-plugin.html
- http://www.wakaleo.com/blog/292-site-generation-in-maven-3
- http://www.javaworld.com/javaworld/jw-02-2006/jw-0227-maven.html