繁体   English   中英

使用google_checks时,Checkstyle Maven插件执行不会因错误而失败

[英]Checkstyle Maven plugin execution doesn't fail on error when using google_checks

我正在使用3.0.0版和Checkstyle 6.18版中的Maven Checkstyle插件

这是我的初始配置:

<properties>
    <maven.checkstyle.plugin.version>3.0.0</maven.checkstyle.plugin.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>${maven.checkstyle.plugin.version}</version>
            <configuration>
                <failsOnError>true</failsOnError>
                <failOnViolation>true</failOnViolation>
            </configuration>
        </plugin>
    </plugins>
</build>

由于存在checkstyle错误,因此运行mvn checkstyle:checkstyle将使构建失败。 这是预期的。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.0.0:check (default-cli) on project demo: Failed during checkstyle execution: There are 311 errors reported by Checkstyle 6.18 with sun_checks.xml ruleset. -> [Help 1]

但是,当我使用与Maven插件捆绑在一起的 google_checks.xml 构建成功完成而没有任何错误(但是target/checkstyle-report.xml仍然显示问题)。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>${maven.checkstyle.plugin.version}</version>
    <configuration>
        <configLocation>google_checks.xml</configLocation>
        <failsOnError>true</failsOnError>
        <failOnViolation>true</failOnViolation>
    </configuration>
</plugin>

我的期望是当我使用google_checks.xml配置时构建失败。 我究竟做错了什么?

更新(04.05.2018):我为此提出了一个错误

在google_checks.xml中,严重性标记为“失败”。 将其更改为错误会导致检查失败。

原版的:

<property name="severity" value="warning"/>

更新:

<property name="severity" value="error"/>

在您的Maven配置中,您还可以调整失败的严重性:

<configuration>
    <encoding>UTF-8</encoding>
    <consoleOutput>true</consoleOutput>
    <failsOnError>true</failsOnError>
    <failOnViolation>true</failOnViolation>
    <violationSeverity>warning</violationSeverity>
    <linkXRef>false</linkXRef>
</configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM