【发布时间】:2018-10-07 00:50:06
【问题描述】:
我在 3.0.0 版和 Checkstyle 6.18 中使用 Maven Checkstyle plugin。
这是我的初始配置:
<properties>
<maven.checkstyle.plugin.version>3.0.0</maven.checkstyle.plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<configuration>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
</plugins>
</build>
运行 mvn checkstyle:checkstyle 将导致构建失败,因为存在 checkstyle 错误。这是意料之中的。
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (default-cli) on project demo: Failed during checkstyle execution: There are 311 errors reported by Checkstyle 6.18 with sun_checks.xml ruleset. -> [Help 1]
但是,当我使用 google_checks.xml which comes bundled with the Maven plugin 时,构建成功且没有任何错误(target/checkstyle-report.xml 仍然显示问题)。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven.checkstyle.plugin.version}</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
</plugin>
我的期望是当我使用google_checks.xml 配置时构建会失败。我做错了什么?
更新(04.05.2018):我为此提出了a bug。
【问题讨论】:
-
你能验证使用 Checkstyle 的 CLI 和 google 配置会产生违规吗?如果是这样,那么您的 Maven 配置就是问题所在。
-
我知道 Maven 是问题所在。我试图找出究竟是什么问题,因为它适用于默认的 Sun 检查。运行 Checkstyle CLI 适用于任何配置。
标签: java maven checkstyle maven-checkstyle-plugin