2017-06-14 59 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'); 
}