java Gradle 子项目构建依赖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32391143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gradle subproject build dependency
提问by Klaus
I have a dependency problem and I do not know how to solve it.
我有一个依赖性问题,我不知道如何解决它。
I have a project A, B and C.
我有一个项目 A、B 和 C。
A needs B and C
A 需要 B 和 C
B needs C
B 需要 C
My directory structure looks like this:
我的目录结构如下所示:
A
|-settings.gradle
|-build.gradle
|-lib
|- B
|- C
settings.gradle content:
settings.gradle 内容:
include 'lib/B'
include 'lib/C'
build.gradle content:
build.gradle 内容:
apply plugin: 'java'
dependencies {
compile project(':lib/B'),
project(':lib/C')
}
project(':lib/B'){
dependencies {
compile project(':lib/C')
}
}
If I do NOT declare the project(':lib/B'){...} part, project B can not be build because of dependencies.
如果我不声明 project(':lib/B'){...} 部分,则由于依赖关系无法构建项目 B。
If I declare the project(':lib/B'){...} part, Gradle tells me : Could not find method compile() for arguments [project ':lib/C'] on org.gradle.api.internal.artifacts.dsl.pendencies.DefaultDependencyHandler_Decorated@221bad.
如果我声明 project(':lib/B'){...} 部分,Gradle 会告诉我:在 org.gradle.api.internal 上找不到参数 [project ':lib/C'] 的方法 compile() .artifacts.dsl.pendencies.DefaultDependencyHandler_Decorated@221bad。
How am I able to solve it, or compile C before B?
我怎样才能解决它,或者在 B 之前编译 C?
PS: Data structure changes are not possible.
PS:无法更改数据结构。
回答by
Please, try to add
请尝试添加
subprojects {
apply plugin: 'java'
}
to your main build.gradle
到你的主要 build.gradle