gpt4 book ai didi

gradle checkstyle 错误 :Expected file collection to contain exactly one file, 但是,它包含 14 个文件

转载 作者:行者123 更新时间:2023-12-03 03:56:18 25 4
gpt4 key购买 nike

我在 Gradle 中使用 Java 8 并尝试将 Google checkstyle 规则添加到构建中,但我得到的是这个错误:

"Expected file collection to contain exactly one file, however, it contains 14 files."



我的配置是:
apply plugin: 'checkstyle'
configurations {
checkstyleConfig
}
def versions = [
checkstyle: '8.8',
]
dependencies {
checkstyleConfig "com.puppycrawl.tools:checkstyle:${versions.checkstyle}"
}
checkstyle {
toolVersion = "${versions.checkstyle}"
config = resources.text.fromArchiveEntry(configurations.checkstyleConfig, 'google_checks.xml')
}

最佳答案

这里的问题是 configurations.checkstyleConfig包含多个 JAR 文件:com.puppycrawl.tools:checkstyle ,以及它的所有传递依赖项。在本地调试问题,我看到这些依赖项被包含在内:

antlr:antlr:2.7.7
com.google.code.findbugs:jsr305:1.3.9
com.google.errorprone:error_prone_annotations:2.1.3
com.google.guava:guava:23.6-jre
com.google.j2objc:j2objc-annotations:1.1
com.puppycrawl.tools:checkstyle:8.8
commons-beanutils:commons-beanutils:1.9.3
commons-cli:commons-cli:1.4
commons-collections:commons-collections:3.2.2
commons-logging:commons-logging:1.2
net.sf.saxon:Saxon-HE:9.8.0-7
org.antlr:antlr4-runtime:4.7.1
org.checkerframework:checker-compat-qual:2.0.0
org.codehaus.mojo:animal-sniffer-annotations:1.14

幸运的是,对此的修复非常简单。您需要做的就是从 Checkstyle 依赖项中排除传递依赖项,脚本的其余部分将按照您希望的方式工作:
dependencies {
checkstyleConfig("com.puppycrawl.tools:checkstyle:${versions.checkstyle}") { transitive = false }
}

关于gradle checkstyle 错误 :Expected file collection to contain exactly one file, 但是,它包含 14 个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58744244/

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