dev@glassfish.java.net

Re: findbugs-maven-plugin

From: Sahoo <Sahoo_at_Sun.COM>
Date: Thu, 05 Feb 2009 09:38:35 +0530

Bill Shannon wrote:
> Maven is always such an adventure... :-(
>
> If I run "mvn findbugs:findbugs", it produces no output. The docs say:
>
> Generates a FindBugs Report when the site plugin is run. The HTML
> report
> is generated for site commands only.
>
> I think that means I have to run "mvn site" to get any output (why?).
> So I do that and it dies with:
>
> [FATAL ERROR] Container realm = plexus.core
> urls[0] = file:/opt/maven/lib/maven-2.0.9-uber.jar
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] org/apache/maven/model/PluginManagement
> org.apache.maven.model.PluginManagement
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Trace
> java.lang.NoClassDefFoundError: org/apache/maven/model/PluginManagement
> at
> org.apache.maven.report.projectinfo.PluginManagementReport.canGenerateReport(PluginManagementReport.java:106)
>
> ...
>
>
> Grumble. Now what?
>
I am definitely the wrong person. You may like to check with the plugin
developers.
>
> So then I try the findbugs:check goal, which says:
>
> Fail the build if there were any FindBugs violations in the source
> code.
> An XML report is put out by default in the target directory with the
> errors.
>
> Yes, it's true, the goal that you would think would produce output
> produces
> no output, and the goal you would think would produce no output produces
> output. What drugs are these people on?!?!
>
> Anyway, running that gives:
>
> The following classes needed for analysis were missing:
> javax.annotation.Nonnull
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] failed with 79 bugs and 0 errors
>
> Despite the error, it did produce the output file.
>
> But if it needed javax.annotation.Nonnull, shouldn't it have included
> a dependency on whatever module defines it?
Seems like a bug in the plugin. See:
https://mailman.cs.umd.edu/pipermail/findbugs-discuss/2008-March/002264.html

Try adding the following dependency in your project as a workaround:

<dependency>
  <groupId>net.sourceforge.findbugs</groupId>
  <artifactId>jsr305</artifactId>
  <version>1.3.2</version>
</dependency>
>
> Well, at least I got an output file, but xml is a pain to read so I
> decide
> to try the GUI with "mvn findbugs:gui". The docs say:
>
> Launch the Findbugs GUI. It will use all the parameters in the POM fle.
>
> The GUI comes up with no knowledge of my files at all. Sigh. Exactly
> what parameters in the POM file is it using?
I don't know much about this plugin nor about findbugs that much. In my
simple project, after I ran "mvn findbugs:check," I could run "mvn
findbugs:gui" and it opened the GUI, but without any details. I had to
open the report from target dir using the File menu of the GUI. So,
something is definitely not correct about the plugin.

Thanks,
Sahoo