简体   繁体   English

如何做IntelliJ android gradle内部模块依赖项?

[英]How to do IntelliJ android gradle intra module dependencies?

I'm comfortable with maven, so gradle doesn't seem like it's a huge jump. 我对Maven感到很满意,所以gradle似乎并没有很大的进步。 But, I cannot figure out how to make intra module dependencies work. 但是,我无法弄清楚如何使内部模块依赖项起作用。

In IntelliJ I created 4 modules like this: 在IntelliJ中,我创建了4个这样的模块:

SharedLib1
FooApp
    FooAppLib
    FooAppMain

The dependencies I want are: 我想要的依赖项是:

FooAppMain -> FooAppLib
FooAppLib -> SharedLib1

In maven all I'd need to do is refer to other things by their group, artifactid, and version. 在Maven中,我所需要做的就是按组,工件ID和版本来引用其他内容。 However, none of the build.gradle files generated contain anything that looks like a group or artifactid, so I don't know how to refer modules to each other. 但是,生成的build.gradle文件都不包含看起来像组或工件ID的任何东西,因此我不知道如何相互引用模块。

Something like this seems appropriate for the FooAppMain build.gradle file: 像这样的事情似乎适合FooAppMain build.gradle文件:

compile project(":FooAppLib")

However, that just doesn't work. 但是,那根本行不通。 There are other dependencies like this: 还有其他类似的依赖项:

compile 'com.android.support:support-v4:19.1.0'

But again, I don't know where to put the group and artifactid values in the build.gradle so I can refer to them. 但是同样,我不知道将group和artifactid值放在build.gradle中的什么位置,所以我可以引用它们。

create a settings.gradle file in the project root and configure the lib project path there. 在项目根目录中创建一个settings.gradle文件,并在那里配置lib项目路径。

include ':app', ':FooAppLib'


project(':FooAppLib').projectDir = file('../yourLibProjectRoot/app')

And then in your build.gradle file, add the dependency to this project 然后在build.gradle文件中,将依赖项添加到该项目中

compile project(":FooAppLib")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IntelliJ 和 Android Gradle 依赖项 - 找不到模块 - IntelliJ and Android Gradle dependencies - unable to find module 如何更改我的 Android Studio Gradle 模块依赖项? - How do I change my Android Studio Gradle Module dependencies? 如何在IntelliJ 13中为Gradle Android项目创建Android测试模块? - How do I create an Android Test Module in IntelliJ 13 for a Gradle Android project? Android Gradle项目(Intellij IDEA)中的依赖项 - Dependencies in Android Gradle project (Intellij IDEA) 为什么gradle android插件不会为intellij idea模块生成依赖项 - Why gradle android plugin doesn't generate dependencies for intellij idea module Android Gradle 在另一个模块中包含模块依赖项 - Android Gradle include module dependencies in another module 如何发送具有远程依赖项(gradle)的Android库(aar)? - How do I ship an Android Library (aar) with remote dependencies (gradle)? 如何在Android Studio中使用Gradle访问依赖项的依赖项? - How to access dependencies of dependencies with gradle in android studio? 如何使用Android Studio和Gradle在Android库.jar中添加模块依赖项? - How to add module dependencies in an Android library .jar using Android Studio and gradle? AndroidStudio - Gradle 中的模块依赖关系 - AndroidStudio - Module Dependencies in Gradle
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM