Maven检查样式作为构建的一部分 [英] Maven check style as a part of the build
本文介绍了Maven检查样式作为构建的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果有一些 checkstyle
错误,是否有可能以某种方式强制maven失败?现在我必须运行 site
目标来生成 javadocs
和 checkstyle
报道。我想在安装
目标上进行,如果checkstyle有一些错误,我需要构建失败。这可能实现吗?
Is there a possibility to somehow force maven to fail the build if there are some checkstyle
errors? Now I have to run site
goal to generate javadocs
and checkstyle
reports. I want to make it on install
goal and if checkstyle has some error I need build to fail. Is this possible to achieve?
现在我在报告maven块中有 checkstyle
:
Now I have my checkstyle
in reporting block of maven:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<configLocation>src/test/resources/checkstyle.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
推荐答案
你需要绑定 checkstyle :检查
到Maven生命周期阶段(例如验证)并将 failOnViolation
设置为true。
You need to bind checkstyle:check
to a Maven lifecycle phase (e.g. validate ) and set failOnViolation
to true.
类似于:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<failOnViolation>true</failOnViolation>
</configuration>
</execution>
</executions>
</plugin>
这篇关于Maven检查样式作为构建的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文