简体   繁体   English

Gradle设置和依赖关系

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM