所以在我的例子中,checkstyle-suppressions.xml
在checkstyle.xml和pom.xml中都指定了:
检查样式.xml:
<module name="SuppressionFilter">
<property name="file" value="checkstyle-suppressions.xml"/>
</module>
绒球.xml
<project>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
我不太确定是否需要在两个文件中定义它,一个带有SuppressionFilter
模块和 pom 中的<suppressionsLocation>
标签。
我想将 https://github.com/openmrs/openmrs-core/blob/master/checkstyle.xml 与其他项目一起使用。但是,当在 pom.xml 中将<configLocation>
设置为https://github.com/openmrs/openmrs-core/blob/master/checkstyle.xml
时,checkstyle-plugin 会失败并显示错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project webservices.rest: Failed during checkstyle configuration: cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter: InvocationTargetException: Unable to find: checkstyle-suppressions.xml -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (validate) on project webservices.rest: Failed during checkstyle configuration
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed during checkstyle configuration
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: cannot initialize module SuppressionFilter - Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter
Caused by: com.puppycrawl.tools.checkstyle.api.CheckstyleException: Cannot set property 'file' to 'checkstyle-suppressions.xml' in module SuppressionFilter
我不太确定是否需要在两个文件中定义它
没必要。如果在 POM 中定义,maven 会将其添加到后台配置中。
检查样式配置期间失败
找不到:检查样式抑制.xml
找不到要加载的文件.
它尝试将文件作为直接文件系统路径(相对路径应基于当前工作目录(、URL 或程序中的资源进行查找。http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter