Java – how do I configure the findbugs Maven plug-in to check only annotation violations such as @ nonnull?

I have implemented the answer to this question, so @ nonnull violation makes the build fail But the problem is, this is to find many other mistakes I don't want to deal with I've read the manual, and no section pops up as a "this is how you configure the section to check"

To me, it should be in here, but the number of options doesn't seem comprehensive enough How do I configure findbugs and only care about findbugs annotations?

I might accept an answer that tells me how to do it without using the Maven plug-in, because I think I can figure out how to convert it into something that the plug-in can use

Solution

This is the findbugs Maven configuration I use:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>findbugs-maven-plugin</artifactId>
    <version>2.4.0</version>
    <configuration>
        <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
        <findbugsXmlOutput>true</findbugsXmlOutput>
        <xmlOutput>true</xmlOutput>
    </configuration>
</plugin>

findbugs-exclude. The XML file is located in the root directory of my project (the same as POM. XML - I should put it in a better place) and configure the findbugs problem I want to ignore This is what's in my exclusion file:

<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
    <Match>
        <Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
    </Match>
    <Match>
        <Package name="com.mypackage.something"/>
    </Match>
</FindBugsFilter>

More information about configuring findbugs filter files in the findbugs manual

In addition, you can change the findbugs Maven plug-in to use only this instead of excludefilterfile, which contains some filters:

<includeFilterFile>findbugs-include.xml</includeFilterFile>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>