gpt4 book ai didi

java - Maven 检查样式作为构建的一部分

转载 作者:IT老高 更新时间:2023-10-28 20:40:25 31 4
gpt4 key购买 nike

如果有一些 checkstyle 错误,是否有可能以某种方式强制 maven 使构建失败?现在我必须运行 site 目标来生成 javadocscheckstyle 报告。我想实现 install 目标,如果 checkstyle 有一些错误,我需要构建失败。这有可能实现吗?

现在我的 checkstyle 在 maven 的报告 block 中:

<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:check 绑定(bind)到 Maven 生命周期阶段(例如 validate )并将 failOnViolation 设置为 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>

关于java - Maven 检查样式作为构建的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12180765/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com