gpt4 book ai didi

java - Gradle 构建失败并出现错误 checkstyleMain FAILED

转载 作者:行者123 更新时间:2023-11-30 05:32:26 25 4
gpt4 key购买 nike

我最近升级了我的项目。

   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'))
}

这是我的项目结构: enter image description here

最佳答案

终于我成功了。感谢马丁的提示。

使用 java 11 时有一个完全不同的策略

使用 Java 11 时,Gradle checkstyle 插件会在守护进程文件夹中搜索suppressions.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>

关于java - Gradle 构建失败并出现错误 checkstyleMain FAILED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57261461/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com