gradle 不支持多级子模块,Gradle将多模块项目中的嵌套子项目添加为另一个子项目的依赖项...

I have a complex, but interesting situation. This is a tree diagram of my folder structure:

root

|___ settings.gradle

|___ p1

|___ p2 // depends on p3/sp1

|___ p3

|____|___sp1

|____|___sp2

I hope that explains the situation.

Now how would I add sp1 as a dependency of p2?

So far in my root setting.gradle, I have

rootProject.name = root

include 'p1'

include 'p2'

include 'p3'

In p2 build.gradle, I have:

dependencies {

compile project (':p3:sp1')

}

But doing this still does not resolve the dependencies in p2; I still get errors about missing definition.

How do I fix this?

Just an aside, how would I resolve other dependencies sp1 might have. Like if it depends on sp2, do I need to declare this somehow even though it is already resolved within p3?

解决方案

Assuming project sp1 and sp2 are subprojects of project p3, if you want to do:

dependencies {

compile project(':p3:sp1')

}

Then you need to change your settings.gradle to:

rootProject.name = root

include ':p1'

include ':p2'

include ':p3' // Keep this if this folder contains a build.gradle

include ':p3:sp1'

include ':p3:sp2'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值