【发布时间】:2014-04-10 06:08:16
【问题描述】:
我有这样的项目设置
+ rootProject
+ module1
+ src
build.gradle
+ module2
+ src
build.gradle
+ src
build.gradle
settings.gradle
rootProject/build.gradle的内容
evaluationDependsOn(':module1')
apply plugin: 'java'
dependencies {
compile project(':module1')
compile project(':module2')
}
task myTask (type: JavaExec) {
main = 'org.gradle.example.Test.Main'
classpath runtimeClasspath
}
module1/build.gradle的内容
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'commons-codec:commons-codec:1.9'
}
module2/build.gradle的内容
apply plugin: 'java'
依赖关系图
root --> module1 --> commons-codec
--> module2
gradle 在构建时使用命令gradle build 在根文件夹中报告此问题
Could not resolve all dependencies for configuration ':compile'.
> Could not find commons-codec:commons-codec:1.9. Required by:
:rootProject:unspecified > rootProject:codec:unspecified
如果我在 rootProject 的构建文件中添加 dependencies 块,它会正常构建。
如您所见,我已经确定了 module1 构建文件中的依赖关系。为什么gradle一直说它无法解决?
我需要将子模块的所有依赖项放在根构建文件中吗?
【问题讨论】:
标签: gradle build.gradle