【发布时间】:2011-08-26 18:17:47
【问题描述】:
我有一个多项目设置(ProjectB -> ProjectA),我正在使用 flatDir 在每个项目中指定一个 lib 目录。
项目A:
repositories {
flatDir name: 'localRepository', dirs: 'lib'
}
dependencies {
compile group: 'com.google.guava', name: 'guava', version: 'r08'
compile group: 'com.miglayout', name: 'miglayout', version: '3.7.4'
testCompile group: 'junit', name: 'junit', version: '4.+'
testCompile group: 'org.easymock', name: 'easymock', version: '2.5.2'
}
项目B:
repositories {
flatDir name: 'localRepository', dirs: 'lib'
}
dependencies {
compile group: 'yan', name: 'yan', version: '5.0.2'
runtime group: 'yan', name: 'jfunutil', version: '5.0.2'
compile project(':ProjectA')
testCompile group: 'junit', name: 'junit', version: '4.+'
testCompile group: 'org.easymock', name: 'easymock', version: '2.5.2'
}
当我对 ProjectB 使用 gradle dependencies 时,会生成正确的依赖关系列表,显示来自 ProjectA 的传递依赖关系(例如,包括 guava-r08)。但是我gradle build的时候,实际用于javac的classpath只包含了ProjectB的直接依赖,以及构建ProjectA生成的jar。
另一个烦恼似乎是 testCompile,我必须重新声明 ProjectB 对 junit 的依赖,否则 gradle dependencies 将不会成功。
非常感谢任何指针 - 我是 Gradle 新手。
【问题讨论】: