[英]Gradle settings and dependencies
Imagine we have two projects: 想象我们有两个项目:
root
|
|--MP
|
|--API
In these project MP
use classes defined in API. 在这些项目MP
使用API中定义的类。 I write settings.gradle
file in the root directory: 我在根目录中写入settings.gradle
文件:
include 'API', 'MP'
and build.gradle in that directory: 并在该目录中build.gradle:
subprojects{
apply plugin : 'java'
repositories{
mavenCentral()
}
version = '1.0'
jar{
manifest{
attributes 'Gradle': 'Multiproject'
}
}
}
But if I don't create the following build.gradle
in MP
: 但是,如果我没有在MP
创建以下build.gradle
:
dependencies {
compile project(':API')
}
it won't work. 它不会工作。 I thought settings.gradle
define that we may use API
in MP
or vice versa during compilation. 我认为settings.gradle
定义了在编译过程中我们可以在MP
使用API
,反之亦然。
This is as designed. 这是按设计的。 You have two subprojects and each of them has its own sources and dependencies. 您有两个子项目,每个子项目都有自己的源代码和依赖项。 Applying the same customization using the subprojects
closure doesn't merge them. 使用subprojects
闭包应用相同的自定义项不会合并它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.