Maven Codehaus plugin findbugs "onlyAnalyze" does not work as expected

Update for the impatient: it's simple, use package.-to scan subpackages instead package.*, as is the case with martoe below!

I can’t make it onlyAnalyzework for my multi-module project: no matter what package (or template) I installed, maven-findbugs-plugin does not evaluate subpackages as I would expect from passing package_name. *.

To prove that I myself or the plugin is to blame (although I always assume this first!), I set up a small Maven project with the following structure:

pom.xml
src/
    main/java/acme/App.java
    main/java/acme/moo/App.java
    main/java/no_detect/App.java

which is very simple!

POM has the following findbugs configuration:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>2.4.0</version>
            <executions>
                <execution>
                    <phase>verify</phase>
                    <goals><goal>findbugs</goal><goal>check</goal></goals>
                </execution>
            </executions>
            <configuration>
                <debug>true</debug>
                <effort>Max</effort>
                <threshold>Low</threshold>
                <onlyAnalyze>acme.*</onlyAnalyze>
            </configuration>
        </plugin>
    </plugins>
</build>

and each App.java has the following code with two obvious violations:

package acme;
import java.io.Serializable;

public class App implements Serializable
{
    private static final class NotSer {
        private String meh = "meh";
    }

    private static final NotSer ns = new NotSer();// Violation: not serializable field

    public static void main( String[] args )
    {
        ns.meh = "hehehe";// Vilation: unused
        System.out.println( "Hello World!" );
    }
}

, no_detect.App , , , findbugs, "onlyAnalyze", acme.*, , , acme.App acme.moo.App .

mvn clean install , , , findbugs, package, install, ( ) , , acme.App acme.moo.App:

<BugInstance category='BAD_PRACTICE' type='SE_NO_SERIALVERSIONID' instanceOccurrenceMax='0'>
<ShortMessage>Class is Serializable, but doesn't define serialVersionUID</ShortMessage>
<LongMessage>acme.App is Serializable; consider declaring a serialVersionUID</LongMessage>
<Details>
  &lt;p&gt; This field is never read.&amp;nbsp; Consider removing it from the class.&lt;/p&gt;
</Details>
<BugPattern category='BAD_PRACTICE' abbrev='SnVI' type='SE_NO_SERIALVERSIONID'><ShortDescription>Class is Serializable, but doesn't define serialVersionUID</ShortDescription><Details>
<BugCode abbrev='UrF'><Description>Unread field</Description></BugCode><BugCode abbrev='SnVI'><Description>Serializable class with no Version ID</Description></BugCode>

: acme.App, acme.moo.App (), no_detect.App ().

onlyAnalyze, , findbugs (Dangling meta character '*' ..).

onlyAnalyze acme.*,acme.moo.*, (acme.App acme.moo.App), , "", , ; , : !

, , / , , ?

XML /, , ...

+5
1

Findbugs manual: ". * .-, "

+10

All Articles