繁体   English   中英

Gradle 构建失败,出现错误 checkstyleMain FAILED

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM