spotbugs是否有可能从纯maven配置中跳过kotlin文件?

问题描述 投票:0回答:1

我可以使用排除*.kt文件

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

spotbugs-exclude-filter.xml中包含:

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

但是,由于spotbugs位于父pom中(由Java和Kotlin项目使用),我更喜欢纯maven解决方案,因此继承项目不需要额外的xml文件。可能吗?

maven kotlin findbugs spotbugs
1个回答
0
投票

SpotBugs假设代码是从Java类编译的(即使类文件可能具有正确的文件名)。如果查看SpotBugs XML报告文件,您将看到SpotBugs的源文件。为了排除Kotlin类,你必须做类似下面的事情,因为Kotlin编译成XxxxxxKt.class

<FindBugsFilter>
    <Match>
        <Source name="~.*Kt\.java"/>
    </Match>
</FindBugsFilter>
© www.soinside.com 2019 - 2024. All rights reserved.