Maven Project Raports

Posted in java by pedro | Wednesday, September 10th, 2008 at 2:21 am

Thanks to maven, all Project I’m involved in can have the same reports. I will describe which reports I’m using and way.

Findbugs

Findbugs report, in my opinion is one of the most important reports. Here you find my config. Version 2.0 is in snapshot repository and I suppose it will be release in nearly future. This report provide as information about static analyses problems. I use it to discover common mistakes, and i configure it to Normal level which is ok to begin work with findbugs.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<threshold>Normal</threshold>
<effort>Max</effort>
</configuration>
</plugin>

Surefire & Cobertura

Next must to have duet is surfire plugin with cobertura. First one serves us test report (about execution) the second one serves us information about code coverage.  The config looks like this. This duet runs test and provides report from them and code coverage information comes from cobertura.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>

PMD and CPD

This duet search duplicated code, and report it. If you want to be DRY, you should use this.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<linkXref>true</linkXref>
<sourceEncoding>utf-8</sourceEncoding>
<targetJdk>1.5</targetJdk>
</configuration>
</plugin>

Checkstyle

Checkstyle provides information about code style violation, I use it with own setting because in my opinion 80 character line for today screens is not so wise decision. And of course I can tune some of checkers.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>checkstyle.xml</configLocation>
</configuration>
</plugin>

JDepend

This one provides information about dependencies in our code, so we can improve design. It also provides us some code metrics, which we can use to plan some refactoring.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>

JXR

Cross reference source generators used by other plugins to make links between raport and the code.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>

Todo

Tag list plugin will keep all configured tags in one beautiful list.

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
<configuration>
<tags>
<tag>TODO</tag>
<tag>FIXME</tag>
<tag>@todo</tag>
<tag>@deprecated</tag>
</tags>
</configuration>
</plugin>

Javadoc

As everybody knows we should write javadocs, and if we … blah blah. Javadoc is ok, but what about javadoc and UML, you can do it. Simply add uml doclet config. Note that you must have UmlGraph installed. You find here more information.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<reportSets>
<reportSet>
<id>html</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
<reportSet>
<id>doccheck</id>
<configuration>
<doclet>gr.spinellis.umlgraph.doclet.UmlGraph</doclet>
<docletArtifact>
<groupId>gr.spinellis.umlgraph</groupId>
<artifactId>umlgraph</artifactId>
<version>4.6</version>
</docletArtifact>
<additionalparam>-attributes</additionalparam>
<additionalparam>-enumerations</additionalparam>
<additionalparam>-enumconstants</additionalparam>
<additionalparam>-operations</additionalparam>
<additionalparam>-qualify</additionalparam>
<additionalparam>-types</additionalparam>
<additionalparam>-visibility</additionalparam>
<additionalparam>
-d ${project.build.directory}/site/doccheck
</additionalparam>
<destDir>doccheck</destDir>
<name>DocCheck</name>
<description>DocCheck documentation.</description>
</configuration>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>

Changelog

Info from our SCM repository.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
</plugin>

There is also project report with information about developer, scm and so on.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>cim</report>
<report>dependencies</report>
<report>issue-tracking</report>
<report>index</report>
<report>summary</report>
<report>scm</report>
<report>project-team</report>
</reports>
</reportSet>
</reportSets>
</plugin>

Do you use another reporting plugin? Fill free to share it into comments.
Bye

2 Responses to “Maven Project Raports”

  1. Brush says:

    Nice post Seba. Have you checked Simian? http://www.redhillconsulting.com.au/products/simian/ It’s commercial if you use if “for profit” but was a nice one last time i’ve checked. How does ir compare to CPD?

  2. pedro says:

    No I haven’t used it, but I try it. Also I found nice source measurement plugin: javancss-maven-plugin.

Leave a Reply

about me

My name is Sebastian Pietrowski. I've finished Warsaw University as Master degree. I started my journey with Java 1.1 with Thread and JDBC programing in 1998 as I worked for merlin.pl. In 1999 I've passed Java Programer Certificate for Java 1.2, and was solution architect of merlin.pl infrastructure when we was moving from pl/sql to J2EE. It was great performance optimization with 10 times more req/sec than in requirements and 85 times faster as original solution.

Currently I work as Expert Software Development Java at F.Hoffmann-La Roche. The company was founded in 1896 and today, Roche employs over 80.000 people. After work I'm involved in activities related to Scala/Lift, Ruby/Rails/Merb, Python/Django. This is because I try to be pragmatic also I'm focused on application performance and tuning with success in my daily work.

My Yoda's motto: Do, or do not. There is no try.