Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add multi-file support to the maven spotbugs plugin #436

Merged
merged 3 commits into from Jul 5, 2022

Conversation

hgschmie
Copy link

The spotbugs plugin only supports multiple files for bug inclusion, exclusion and baseline definition as comma-separated values in the single properties. This makes it very hard to use multiple sets of files in multi-module projects. One basically ends up with overriding the value in every module.

This patch adds additional list support for <includeFilterFile>, <excludeFilterFile> and <excludeBugsFile> as

<includeFilterFiles>
  <includeFilterFile>...</includeFilterFile>
  <includeFilterFile>...</includeFilterFile>
</includeFilterFiles>

<excludeFilterFiles>
  <excludeFilterFile>...</excludeFilterFile>
  <excludeFilterFile>...</excludeFilterFile>
</excludeFilterFiles>

<excludeBugsFiles>
  <excludeBugsFile>...</excludeBugsFile>
  <excludeBugsFile>...</excludeBugsFile>
</excludeBugsFiles>

This allows the use of the maven combine.children setting to dynamically control the set of files for each subproject, e.g.

Main project:

[parent pom]
<excludeFilterFiles>
  <excludeFilterFile>globalFilterFile.xml</excludeFilterFiles>
<excludeFilterFiles>

Sub module A:

[inherits from parent pom]
<excludeFilterFiles combine.children="append">
  <excludeFilterFile>moduleAFilterFile.xml</excludeFilterFiles>
<excludeFilterFiles>

Sub module B:

[inherits from parent pom]
<excludeFilterFiles combine.children="append">
  <excludeFilterFile>moduleBFilterFile.xml</excludeFilterFiles>
<excludeFilterFiles>

Thus having the globalFilterFile.xml and moduleAFilterFile.xml applied to Sub module A and globalFilterFile.xml and moduleBFilterFile.xml applied to Sub module B.

For large projects, this dramatically simplifies configuring spotbugs.

This PR contains integration tests for all the changes (and some for the filter bugs that should have been there. :-) )

Spotbugs always supported multiple files as a comma-separated list in the <includeFilterFile> configuration option.

This change also adds support for multiple files as a list:

<includeFilterFiles>
  <includeFilterFile>...</includeFilterFile>
  <includeFilterFile>...</includeFilterFile>
<includeFilterFiles>

This allows using pom inheritance to control multiple files.

Includes integration test to verify function.
Spotbugs always supported multiple files as a comma-separated list in the <excludeFilterFile> configuration option.

This change also adds support for multiple files as a list:

<excludeFilterFiles>
  <excludeFilterFile>...</excludeFilterFile>
  <excludeFilterFile>...</excludeFilterFile>
<excludeFilterFiles>

This allows using pom inheritance to control multiple files.

Includes integration test to verify function.
Spotbugs always supported multiple files as a comma-separated list in the <excludeBugsFile> configuration option.

This change also adds support for multiple files as a list:

<excludeBugsFiles>
  <excludeBugsFile>...</excludeBugsFile>
  <excludeBugsFile>...</excludeBugsFile>
<excludeBugsFiles>

This allows using pom inheritance to control multiple files.

As there were no integration tests for the bug baseline files, adds integration tests for

- single bug exclusion file
- multiple bug exclusion files, comma separated
- multiple bug exclusion files as list
@hazendaz hazendaz merged commit 294077e into spotbugs:spotbugs Jul 5, 2022
@hazendaz
Copy link
Member

hazendaz commented Jul 5, 2022

@hgschmie Thanks for this addition. This will be in 4.7.1.0 release. I'll adjust the since items separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants