maven - 运行 Maven Checkstyle 并因错误而失败
问题描述
除此之外mvn test
,我想运行 Maven 的构建过程,它应该会因违规而失败。我在 pom.xml 中尝试了不同的选项,但没有任何效果。failOnViolation
并failsOnError
没有帮助。
我可以运行mvn checkstyle:check
并将错误输出到控制台(起诉<consoleOutput>true</consoleOutput>
)。但是我怎样才能运行 checkstyle 并让它在违规时失败?
这是我到目前为止所尝试的:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<failOnViolation>true</failOnViolation>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
解决方案
正确的方法是修改violationSeverity
值。
<configuration>
<violationSeverity>warning</violationSeverity>
...
</configuration>
这设置了被视为违规的最低严重性级别。有效值为“错误”、“警告”和“信息”。更多信息:https ://maven.apache.org/plugins/maven-checkstyle-plugin/check-mojo.html
推荐阅读
- reactjs - Reactjs:无法在 customBodyRender 中添加更新文本字段
- python - 为什么 j 在 while 循环中不增加?
- reactjs - 每次调用组件时都会渲染反应组件之外的变量?
- php - 从 htaccess 迁移到 NGINX 配置
- excel - Excel IE 自动化,试图将我正在寻找的值变成一个变体
- python - 无法在 Python 中执行 OLS 回归的卡方检验统计量
- python - 如何使用 Aitken 的 delta-squared 方法加速系列的收敛?
- python - 切换不工作的“键盘”Python 和 Tkinter
- spring-boot - 如何在 Spring Cloud 微服务中获取当前登录用户?
- reactjs - 推送到 GitHub 页面时响应应用程序错误