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. During my studies I started work for merlin.pl. The primary language I use is Java but I have also programmed in Python, Ruby and Scala. I worked as a technical solution architect at merlin.pl. infrastructure when we were moving from PL/SQL to J2EE. I engineering a great performance optimized solution that made the application 10 times faster than requirements and 85 times faster as original solution.

Currently, I am working as a Senior Expert at F.Hoffmann-La Roche to help define future roadmap in design and development of Enterprise software at Roche and Genentech and build adoption for new technologies. I'm continuously mentoring new developers, helping them understand how important test driven development is and empowering them to get better at their daily job. I'm involved in many activities which brings new technologies for better and faster development. You can find more details on my LinkedIn profile.

But don’t get me wrong, I am not your typical nerd. I'm a pleasant guy that you can drink a glass of wine with me and talk about a range of topics with. My leisure activities include playing basketball, soccer and listening to music. I try to be pragmatic while staying focused on application performance and tuning with success in my daily work.

My favorite quote from Yoda's and my life’s motto is: Do, or do not. There is no try.