我试图了解Gradle构建依赖关系,但是在使用Gradle网站上的示例时遇到了麻烦,想知道是否有人可以提供帮助。
在他们网站的Adding dependencies to a task部分中,以下代码将保存在 build.gradle 中:
project('projectA') {
task taskX {
dependsOn ':projectB:taskY'
doLast {
println 'taskX'
}
}
}
project('projectB') {
task taskY {
doLast {
println 'taskY'
}
}
}
他们说 gradle -q taskX的输出是:
> gradle -q taskX
taskY
taskX
但是我得到了
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/x/build.gradle' line: 3
* What went wrong:
A problem occurred evaluating root project 'x'.
> Project with path ':projectA' could not be found in root project 'x'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
使用--stacktrace
,我得到以下信息:
Caused by: org.gradle.api.UnknownProjectException: Project with path ':projectA' could not be found in root project 'x'.
注意:此build.gradle
文件是/tmp/x
文件夹中的唯一文件。
------------------------------------------------------------
Gradle 3.4.1
------------------------------------------------------------
Build time: 2012-12-21 00:00:00 UTC
Revision: none
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.10.3 compiled on July 19 2018
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Linux 4.15.0-43-generic amd64