2017-06-14 28 views
0

我正在尝试将checkstyle添加到我的build.gradleCheckdle with 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模块通过<!---->(即禁止)使CheckStyle的效果很好缠绕。

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

回答

1

你需要在你的摇篮文件中定义属性:

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