[英]Gradle build failes getting an error checkstyleMain FAILED
我最近升級了我的項目。
spring boot: 2.1.6
gradle: 4.10.2
java version 11
jacoco : 0.8.1
checkstyle: 8.1
我的項目構建失敗並收到錯誤消息:
任務:checkstyleMain 失敗
.gradle\\daemon\\4.10.2\\etc\\checkstyle\\checkstyle-suppressions.xml(系統找不到指定的路徑)
這是我的 gradle 構建文件:
jacoco {
toolVersion = '0.8.1'
}
jacocoTestReport {
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'com/emp/contacts/domain',
'com/emp/MyApplication.class'
])
})
}
}
checkstyle {
toolVersion = '8.1'
configFile = new File(rootDir, 'etc/checkstyle/checkstyle.xml')
System.setProperty('checkstyle.cache.file', String.format('%s/%s',
buildDir, 'checkstyle.cachefile'))
}
嘗試像這樣引用它(這些配置 XML 都可以放在那里):
configFile file("${project.rootDir}/config/checkstyle.xml")
聲明絕對路徑時應找到checkstyle-suppressions.xml
。
最后我讓它工作了。 感謝馬丁的提示。
使用 java 11 時有一個完全不同的策略
使用 Java 11 時,Gradle checkstyle 插件在守護程序文件夾中搜索抑制.xml
這篇文章對我有幫助https://github.com/gradle/gradle/issues/8286
這是我必須在我的項目中制作才能使其工作的內容
在 build.gradle
checkstyle {
configDir = file("$rootProject.projectDir/etc/checkstyle")
}
在 checkstyle.xml
<!-- Suppression file -->
<module name="SuppressionFilter">
<property name="file" value="${config_loc}/checkstyle-suppressions.xml"/>
</module>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.