我一直在迭代我的第一个 Gradle 插件中的功能。我很早就确定我需要 commons-io,所以我添加了对 commons-io 2.4 的依赖,它是最新版本。
这已经有一段时间了,构建从命令行工作,并且在 Eclipse 中没有错误。
我刚开始尝试集成一些使用“FileUtils.write(File,String)”的代码。我以前不需要那种方法。我在 Eclipse 中把所有东西都去掉了,然后我尝试了一个命令行构建。
这失败了,错误如下:
... error: cannot find symbol
FileUtils.write(serviceLoaderFile,
^
symbol: method write(File,String)
location: class FileUtils
这让我很困惑。我去了 Eclipse 中的失败行,没有指出任何问题。我导航到“write()”方法,对我来说它看起来不错。然后我使用“--debug”运行我的命令行构建以获取一些线索。
当我找到“javac”行时,我发现“$GRADLE_HOME\lib\commons-io-1.4.jar”(其中“GRADLE_HOME”只是我的 Gradle 2.3 发行版)在我的依赖项 jar 之前的类路径中。然后我检查了 1.4 jar 中的代码,并确定该版本中的“FileUtils”类没有“write”方法。
我该怎么办?
更新:
我想我的“依赖项”块可能很有用,就是这样:
dependencies {
compile ("org.codehaus.groovy:groovy-all:2.3.9")
compile gradleApi()
compile "org.opendaylight.yangtools:yang-parser-impl:0.7.0-SNAPSHOT"
compile "org.opendaylight.yangtools:binding-java-api-generator:0.7.0-SNAPSHOT"
compile "org.opendaylight.yangtools:binding-generator-api:0.7.0-SNAPSHOT"
compile "org.opendaylight.yangtools:binding-generator-impl:0.7.0-SNAPSHOT"
compile "org.opendaylight.controller:yang-jmx-generator:0.3.0-SNAPSHOT"
compile "commons-io:commons-io:2.4"
testCompile("org.spockframework:spock-core:1.0-groovy-2.3") {
exclude group: "org.codehaus.groovy"
}
我尝试注释掉“gradleApi”参考,但没有效果。我还尝试为与“groovy-all”引用关联的 commons-io 添加“排除”,但这似乎也没有任何区别。}