即使`failsOnError`设置为`true`,Maven Checkstyle插件也不会在构建过程中失败。

时间:2018-08-24 13:58:44

标签: java maven

我的项目执行严格的样式,因此我运行maven-checkstyle-plugin作为构建的一部分。

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-checkstyle-plugin</artifactId>
  <version>${maven-checkstyle.version}</version> // 3.0.0
  <executions>
    <execution>
      <id>checkstyle</id>
      <phase>validate</phase>
      <goals>
        <goal>check</goal>
      </goals>
      <configuration>
        <configLocation>google_checks.xml</configLocation>
        <encoding>UTF-8</encoding>
        <consoleOutput>true</consoleOutput>
        <failsOnError>true</failsOnError>
      </configuration>
    </execution>
  </executions>
</plugin>

运行构建时,我看到插件正在运行并检查样式,但是由于设置了true标志,因此在出现样式错误时应该会失败。

任何原因使其继续运行并且构建成功吗?

[INFO] --- maven-checkstyle-plugin:3.0.0:check (checkstyle) @ demo-api ---
[INFO] Starting audit...
...
...
[WARN] /Users/jeeves/git/jeeves/demo/src/main/java/com/demo/api/routes/UserRoutes.java:9:57: Parameter name 'BASE_PATH' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [ParameterName]
[WARN] /Users/jeeves/git/jeeves/demo/src/main/java/com/demo/api/routes/UserRoutes.java:13: Line is longer than 100 characters (found 102). [LineLength]
Audit done.
...
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.153 s
[INFO] Finished at: 2018-08-24T09:53:57-04:00
[INFO] Final Memory: 37M/806M
[INFO] ------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:2)

阅读日志:

$("#example").on('search.dt', function() {
    alert(table.column( 0, {page:'current'} ).data().sum() );
});

这些是警告而非错误,因此[WARN] /Users/jeeves/git/jeeves/demo/src/main/java/com/demo/api/routes/UserRoutes.java:9:57: Parameter name 'BASE_PATH' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'. [ParameterName] [WARN] /Users/jeeves/git/jeeves/demo/src/main/java/com/demo/api/routes/UserRoutes.java:13: Line is longer than 100 characters (found 102). [LineLength] Audit done. 将不会触发。

<failsOnError>true</failsOnError>中添加以下几行应会改变行为:

configuration

请参阅maven-checkstyle-plugin-2.16的文档: