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();
public static void main( String[] args )
{
ns.meh = "hehehe";
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>
<p> This field is never read.&nbsp; Consider removing it from the class.</p>
</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 /, , ...