Java Maven Checkstyle插件没有';即使'failsOnError'设置为'true',也不会在生成过程中失败`
我的项目强制执行严格的样式,因此我将Java Maven Checkstyle插件没有';即使'failsOnError'设置为'true',也不会在生成过程中失败`,java,maven,maven-checkstyle-plugin,Java,Maven,Maven Checkstyle Plugin,我的项目强制执行严格的样式,因此我将maven checkstyle插件作为构建的一部分运行 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-checkstyle-plugin</artifactId> <version>${maven-checkstyle.version}</version> // 3.0
maven checkstyle插件作为构建的一部分运行
<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>
阅读日志:
[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.
这些是警告而不是错误,因此不会触发true
将以下行添加到配置中应更改行为:
<violationSeverity>warning</violationSeverity>
<failOnViolation>true</failOnViolation> <!-- defaults as true, can be omitted -->
警告
真的
见以下文件:
- 定义违规严重性的级别
- 发生冲突时触发“失败”事件
顺便说一句,我不确定故障违规是否必要。将violationSeverity
设置为warning
应该足够了。@user2248785默认情况下,failOnViolation
将设置为true
,我们不需要显式设置它。
<violationSeverity>warning</violationSeverity>
<failOnViolation>true</failOnViolation> <!-- defaults as true, can be omitted -->