0

I'm able to exclude *.kt files using

<plugin>
    <groupId>com.github.spotbugs</groupId>
    <artifactId>spotbugs-maven-plugin</artifactId>
    <configuration>
        <excludeFilterFile>spotbugs-exclude-filter.xml</excludeFilterFile>
    </configuration>
</plugin>

and in spotbugs-exclude-filter.xml containing:

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

However, with spotbugs being in a parent pom (used by both Java and Kotlin projects) I'd prefer a pure maven solution so inheriting projects don't need that additional xml file. Is it possible?

Arboreal Shark
  • 2,221
  • 3
  • 17
  • 12
  • 1
    Based on the documentation you can create a separate artifact which contains the configuration. this can be either within your multi module build or a complete separate artifact see https://spotbugs.github.io/spotbugs-maven-plugin/examples/multi-module-config.html – khmarbaise Mar 08 '19 at 12:04

2 Answers2

1

SpotBugs makes the assumption that the code was compiled from Java classes (even though the class file is likely to have the correct filename). If you look at the SpotBugs XML report file, you will see the source files according to SpotBugs. In order to exclude Kotlin classes you will have to do something like below because Kotlin compiled to XxxxxxKt.class

<FindBugsFilter>
    <Match>
        <Source name="~.*Kt\.java"/>
    </Match>
</FindBugsFilter>
h3xStream
  • 6,293
  • 2
  • 47
  • 57
0

In configuration of plugin use includeFilterFile instead excludeFilterFile.

And change pattern from "~.*\.kt" to "~.*Kt\.java".