SpotBugs Maven 插件排除目录
SpotBugs Maven Plugin exclude a directory
我用SpotBugs Maven Plugin for a static analysis and I would like to exclude a directory from the inspection. Looking at the spotbugs:check
goal documentation, it seems that it is not possible to configure the plugin is such a way. I also checked documentation for a SpotBugs filter file.
在 Apache Maven PMD 插件中,这可以通过使用 excludeRoots 参数来完成:
<excludeRoots>
<excludeRoot>target</excludeRoot>
</excludeRoots>
是否可以从 SpotBugs 检查中排除目录?
可以使用 SpotBugs 从检查中排除一个目录,尽管该方法与您为 PMD 描述的方法不同。这是一个两步过程:
首先 create an XML filter file 指定要排除的目录的条件。
然后,在 pom.xml 中使用可选的 <excludeFilterFile>
设置引用该文件。不幸的是,the documentation for that setting 非常简短。
举个简单的例子:
创建一个名为 ignore.xml 的过滤器文件,其中包含以下内容,该文件引用名为 mydir 的目录:
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Source name="~mydir\..*"/>
</Match>
</FindBugsFilter>
the <Source>
tag is here. See the section on Java element name matching 的文档,详细了解如何指定 <Source>
的 name。
然后在pom.xml中,在spotbugs-maven-plugin的规范中,包含一个<excludeFilterFile>
标记,以便 SpotBugs 忽略 mydir:
<configuration>
<excludeFilterFile>ignore.xml</excludeFilterFile>
</configuration>
备注:
还有一个<includeFilterFile>
标签。请参阅 the usage documentation.
中标题为 将哪些错误过滤器指定为 运行 的部分
与 Source
一样,SpotBugs 还提供了几种其他方法来指定要包含或排除检查的代码。请参阅 Package
、Class
、Method
、Local
、Field
和 Type
标签的过滤器文件文档。
我用SpotBugs Maven Plugin for a static analysis and I would like to exclude a directory from the inspection. Looking at the spotbugs:check
goal documentation, it seems that it is not possible to configure the plugin is such a way. I also checked documentation for a SpotBugs filter file.
在 Apache Maven PMD 插件中,这可以通过使用 excludeRoots 参数来完成:
<excludeRoots>
<excludeRoot>target</excludeRoot>
</excludeRoots>
是否可以从 SpotBugs 检查中排除目录?
可以使用 SpotBugs 从检查中排除一个目录,尽管该方法与您为 PMD 描述的方法不同。这是一个两步过程:
首先 create an XML filter file 指定要排除的目录的条件。
然后,在 pom.xml 中使用可选的
<excludeFilterFile>
设置引用该文件。不幸的是,the documentation for that setting 非常简短。
举个简单的例子:
创建一个名为 ignore.xml 的过滤器文件,其中包含以下内容,该文件引用名为 mydir 的目录:
<?xml version="1.0" encoding="UTF-8"?> <FindBugsFilter> <Match> <Source name="~mydir\..*"/> </Match> </FindBugsFilter>
the
<Source>
tag is here. See the section on Java element name matching 的文档,详细了解如何指定<Source>
的 name。然后在pom.xml中,在spotbugs-maven-plugin的规范中,包含一个
<excludeFilterFile>
标记,以便 SpotBugs 忽略 mydir:<configuration> <excludeFilterFile>ignore.xml</excludeFilterFile> </configuration>
备注:
还有一个
<includeFilterFile>
标签。请参阅 the usage documentation. 中标题为 将哪些错误过滤器指定为 运行 的部分
与
Source
一样,SpotBugs 还提供了几种其他方法来指定要包含或排除检查的代码。请参阅Package
、Class
、Method
、Local
、Field
和Type
标签的过滤器文件文档。