排除Maven Checkstyle插件报告中的类 [英] Excluding classes in Maven Checkstyle plugin reports
问题描述
我有一个Maven 2项目,我想配置我的Checkstyle报告插件,以便只分析我的一些类。我找到了 maven.checkstyle.excludes
属性,但是尽管将其作为命令行参数传递(使用 -D = maven.checkstyle.excludes = ...
)我无法让它发挥作用。我在Plugin文档页面上找不到任何内容。理想情况下,我希望能够在我的POM的< configuration>
部分进行设置。
I have a Maven 2 project and I want to configure my Checkstyle report plugin so that only some of my classes are analysed. I have found the maven.checkstyle.excludes
property, but despite passing this as a command line parameter (using -D=maven.checkstyle.excludes=...
) I can't get it to work. I can't find anything on the Plugin documentation page. Ideally I want to be able to set this in the <configuration>
section of my POM.
推荐答案
如果这个问题是关于Maven 2的,那么该属性是 排除
并以逗号分隔的列表蚂蚁模式。所以要么在命令行上传递:
If this question is about Maven 2, then the property is excludes
and takes a comma-separated list of Ant patterns. So either pass this on the command line:
-Dexcludes=**/generated/**/*
或者在插件配置中设置它:
Or set it up in the plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/generated/**/*</excludes>
</configuration>
</plugin>
另一种选择是使用抑制过滤器。
例如,您可以使用 SuppressionCommentFilter
来抑制包含<$ c $的评论之间的审核事件c> CHECKSTYLE:OFF 以及包含 CHECKSTYLE:ON
的注释(然后只需将这些注释添加到类或部分代码中你不想检查。)
For example you could use the SuppressionCommentFilter
to suppress audit events between a comment containing CHECKSTYLE:OFF
and a comment containing CHECKSTYLE:ON
(then just add these comments to the classes or parts of the code you don't want to check).
这篇关于排除Maven Checkstyle插件报告中的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!