maven checkstyle插件创建一个输出文件,但检查失败

时间:2018-07-20 20:05:29

标签: maven checkstyle

我对Maven Checkstyle插件有疑问。问题是它创建了一个输出文件,但失败了,因为该文件的确以换行​​符结尾(插件应检查该行):

[ERROR] target/checkstyle-result.xml:[0] (misc) NewlineAtEndOfFile: File does not end with a newline.

我尝试使用以下方法从该插件中排除目标目录:

<properties>
        <checkstyle.excludes>**/target/**</checkstyle.excludes>
</properties>

但是什么也没做。

该插件本身是在父pom.xml文件中配置的,因此我对此没有任何控制。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并解决了。您的规则(以及之前的规则)存在的问题如下:

  • **/target/**与文件target/checkstyle-result.xml不匹配。更好的方法是**/target/**/*
  • 由于您的XML不是源代码而是资源,因此您应该使用checkstyle.resourceExcludes属性。