我有一个多项目设置(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'
}
当我gradle dependencies
用于 ProjectB 时,会生成正确的依赖关系列表,显示来自 ProjectA 的传递依赖关系(例如,包括 guava-r08)。但是,当 I 时gradle build
,实际用于 javac 的类路径仅包括 ProjectB 的直接依赖项,以及构建 ProjectA 生成的 jar。
另一个烦恼似乎是 testCompile,我必须重新声明 ProjectB 对 junit 的依赖,否则gradle dependencies
不会成功。
任何指针都非常感谢 - 我是 Gradle 的新手。