我在 3.0.0 版和 Checkstyle 6.18 中使用Maven Checkstyle 插件。
这是我的初始配置:
<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
它与 Maven 插件捆绑在一起时,构建成功而没有任何错误(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):我为此提出了一个错误。