Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

maven - SpotBugs ignore whole directory in src folder

Hy,

In my maven setup, I have a plugin, which generates source code and puts it into my java src folder.
As this code is auto generated, I'd like to exclude it from all SpotBugs checks.

The file structure is as follows:

-- src
    |
    --- generated    <-- No files in this folder should be checked
    |
    --- main         <-- The "normal" java files, which should be checked

I tried a few things including the following, but nothing works:

<FindBugsFilter>
  <Match>
    <Source name="~.*generated.*"/>
  </Match>
</FindBugsFilter>

This is my plugin configuration in the pom.xml:

<plugin>
  <groupId>com.github.spotbugs</groupId>
  <artifactId>spotbugs-maven-plugin</artifactId>
  <version>4.2.0</version>
  <configuration>
    <excludeFilterFile>config/spotbugs-excludes.xml</excludeFilterFile>
    <effort>Max</effort>
    <threshold>Normal</threshold>
    <failOnError>true</failOnError>
    <includeTests>false</includeTests>
    <spotbugsXmlOutput>true</spotbugsXmlOutput>
    <xmlOutput>true</xmlOutput>
    <plugins>
      <plugin>
        <groupId>com.h3xstream.findsecbugs</groupId>
        <artifactId>findsecbugs-plugin</artifactId>
        <version>1.11.0</version>
      </plugin>
      <plugin>
        <groupId>com.mebigfatguy.fb-contrib</groupId>
        <artifactId>fb-contrib</artifactId>
        <version>7.4.3.sb</version>
      </plugin>
    </plugins>
  </configuration>
  <executions>
    <execution>
      <goals>
        <goal>check</goal>
      </goals>
      <phase>generate-test-sources</phase>
    </execution>
  </executions>
</plugin>

Greets
Chris

question from:https://stackoverflow.com/questions/65886798/spotbugs-ignore-whole-directory-in-src-folder

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...