Wednesday, 5 March 2008

Maven reporting plugins - useful for generated reports in the Maven-generated project site

We're currently setting up CruiseControl at work and are looking to
have more documentation on various aspects of each project. Adding
these settings to a Maven projects pom.xml would generate a lot of
useful information that would cover our needs.


<reporting>
<plugins>
<plugin>
<artifactId>maven-changes-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>

<!--

<plugin>

This plug-in provides functionality for accessing FindBugs
from Maven.

<artifactId>maven-findbugs-plugin</artifactId>
</plugin>

-->


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<!--
The JXR plugin produces a cross-reference of the project's sources.
The generated reports make it easier for the user to
reference or find
specific lines of code. It is also handy when used with
the PMD plugin
for referencing errors found in the code.
for multi-module projects, see:

http://maven.apache.org/plugins/maven-jxr-plugin/examples/aggregate.html

-->
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<!--
The PMD plugin allows you to automatically run the PMD
code analysis tool on your
project's source code and generate a site report with its
results. It also supports
the separate Copy/Paste Detector tool (or CPD) distributed
with PMD.
-->
<artifactId>maven-pmd-plugin</artifactId>
<configuration>
<linkXref>true</linkXref>
<targetJdk>1.5</targetJdk>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
</plugin>
<plugin>
<!--
This plugin is used to inform your users of the changes
that have occured
between different releases of your project. The plugin can
extract these changes,
either from a changes.xml file or from the JIRA issue
management system,
and present them as a report.
-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>

===================

Updated 6 March 2008: Commented out the Findbugs plugin entry because I can't get it to work yet. The settings above are actually for Maven1. To use the Maven2 plugin it should be like this:


<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>1.1.1</version>
</plugin>




We are using Artifactory, but for some reason I get this Maven error:

[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project for plugin 'org.codehaus.mojo:findbugs-maven-plugin': POM 'org.codehaus.mojo:findbugs-maven-plugin' not found in repository: Unable to download the artifact from any repository

org.codehaus.mojo:findbugs-maven-plugin:pom:1.1.1

from the specified remote repositories:
everything-else (http://192.168.1.1:7070/artifactory/releases),
snapshots (http://192.168.1.1:7070/artifactory/snapshots-only),
central (http://192.168.1.1:7070/artifactory/repo1)


However, when I got to repo1.maven.org (which is in my proxy configs), the Findbugs plugin is there at:

http://repo1.maven.org/maven2/org/codehaus/mojo/findbugs-maven-plugin/

So why is Maven (or Artifactory) unable to retrieve this plugin?

Again, what is going on here?

I guess I should test this first by removing Artifactory from the picture, removing the proxy settings from my settings.xml. If it fails, then it's a Maven issue. If it works, maybe it's Artifactory.

========================

Update:

Removed the Artifactory settings and Maven was able to download the plugin correctly. Maybe I should expire some caches and see if it is able to get the plugin?

4 comments:

Neitcouq said...

Hi, guy. I meet the same problem as you. My Artifactory doesn't down load the .pom file :
Downloading: http://172.16.100.158:8000/artifactory/repo/org/codehaus/mojo/findb
ugs-maven-plugin/1.2-SNAPSHOT/findbugs-maven-plugin-1.2-SNAPSHOT.pom
Downloading: http://172.16.100.158:8000/artifactory/repo/org/codehaus/mojo/findb
ugs-maven-plugin/1.2-SNAPSHOT/findbugs-maven-plugin-1.2-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

GroupId: org.codehaus.mojo
ArtifactId: findbugs-maven-plugin
Version: 1.2-SNAPSHOT

Reason: Unable to download the artifact from any repository

org.codehaus.mojo:findbugs-maven-plugin:pom:1.2-SNAPSHOT

The error occurs when I use "mvn site". But when I use " mvn findbugs:findbugs", it works well ! And when I remove Artifactory, everything ok !
Have you solve this problem ? I had spent all day but nothing change !

kman said...

I'm getting the exact same behaviour. When run as mvn findbugs:findbugs it works fine, but when run with mvn site it tries to look for 1.2-SNAPSHOT instead of 1.2 used by the findbugs goal. As a temporary solution (haven't tested though) I guess you coud manually install the 1.2-SNAPSHOT version in your local repository.

I'm new to maven (just being using it since 3 days ago) and don't really know where to start looking. If I find the solution I'll post it here. If anyone else does please help our poor souls.

kman said...

Oops, found it: Since I copy-pasted the sample from the findbugs plugin site, I was sloppy and didn't notice that it contained a :

>version<1.1.1 or 1.2-SNAPSHOT>/version<

I just set it to 1.2 and worked fine. I still don't know why findbugs goal worked.

krangsquared said...

hey kman, my guess is that findbugs works because you already have 1.2 installed locally, whereas the findbugs that the mvn:site plugin tries to use is the 1.2-SNAPSHOT because that's what's hardcoded in the site-plugin that you have... perhaps doing mvn -U to update the plugins might be of some help? anyway, you already fixed your problem...

Apparently, the next Maven will do more work towards fixing plugin versions, so that there's more predictability in what maven plugin versions you have.