Gradle 1.11给我一个弃用警告:
robert@pferdeapfel:~/prj> gradle --version | grep Gradle
Gradle 1.11
robert@pferdeapfel:~/prj> gradle compileJava
Converting class org.gradle.api.internal.file.DefaultSourceDirectorySet to File using
toString() method has been deprecated and is scheduled to be removed in Gradle 2.0.
Please use java.io.File, java.lang.String, java.net.URL, or java.net.URI instead.
:compileAcctJava
:processAcctResources UP-TO-DATE
:acctClasses
:resources
:acct UP-TO-DATE
:beans UP-TO-DATE
:svninfo UP-TO-DATE
:settings UP-TO-DATE
:compileJava UP-TO-DATE
BUILD SUCCESSFUL
Total time: 10.865 secs
和Gradle 2.0无法构建:
robert@pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle --version | grep Gradle
Gradle 2.0
robert@pferdeapfel:~/prj> /usr/local/gradle-2.0/bin/gradle -i compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':compileAcctJava'.
> Cannot convert the provided notation to a File or URI: acct Java source.
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option
to get more log output.
BUILD FAILED
Total time: 3.676 secs
但是,我不知道为什么以及在我的构建脚本中的问题所在.
我已按照http://www.gradle.org/docs/current/userguide/java_plugin.html#sec%3asource_sets中的描述定义了源集,因为我的项目不遵循默认的项目布局.
sourceSets {
...
acct {
java {
srcDir "src"
srcDirs("src") {
include "my/program/some/package/Acct.java"
}
}
}
...
}
我确实有一些依赖项定义,但不适用于acct;这只是一个简单的枚举,用作代码生成的基础.它没有依赖关系.即使我添加如下的虚拟依赖项,我也会得到同样的错误.
dependencies {
...
acctCompile junit
...
}
我该如何解决这个问题,或者如何才能找到更多关于究竟出了什么问题?
我没有发现Gradle的输出–debug和–stacktrace有用.
最佳答案 没有srcDirs(“src”){include“my / program / some / package / Acct.java”}这样的表示法.尝试:
sourceSets {
acct {
java {
srcDirs = ["src"] // replaces default rather than adding another dir
include "my/program/some/package/Acct.java"
}
}
}