【问题标题】:Checkstyle with Gradle使用 Gradle 的 Checkstyle
【发布时间】:2017-06-14 18:06:31
【问题描述】:

我正在尝试将 checkstyle 添加到我的 build.gradle

Checkstyle模板为commons-math3,可从here访问。

但此文件使用${checkstyle.header.file} 来检查每个源文件顶部的许可证声明。

<!-- Verify that EVERY source file has the appropriate license -->
<module name="Header">
  <property name="headerFile" value="${checkstyle.header.file}"/>
</module>

所以我在build.gradle 中添加了以下短语:

checkstyle {
    configFile = rootProject.file("commons-math-checkstyle.xml")
    headerFile = rootProject.file("license-header.txt")
    toolVersion = '7.8.1'
}

但它会出错。

build.gradle 中删除headerFile = rootProject.file("license-header.txt") 并使checkstyle xml 文件中的Header 模块被&lt;!----&gt; 包装(即禁用)使得checkstyle 工作良好。

如何在我的build.gradle 文件中声明checkstyle.header.file

【问题讨论】:

    标签: gradle checkstyle


    【解决方案1】:

    您需要在 Gradle 文件中定义属性:

    checkstyle {
        toolVersion '7.8.1';
        configFile file('commons-math-checkstyle.xml');
        configProperties 'checkstyle.header.file': file('license-header.txt');
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 2015-12-03
      • 2014-12-20
      • 2016-11-20
      • 2018-05-22
      相关资源
      最近更新 更多