[英]Gradle task of project depend on task of other project
I have an android project with two different apps.我有一个带有两个不同应用程序的 android 项目。
This is my current structure:这是我目前的结构:
appA/
buid.gradle
...
appB/
buid.gradle
...
settings.gradle
gradlew
settings.gradle is the following: settings.gradle如下:
include ':appA'
include ':appB'
To test appA , appB needs to be installed on the emulator.要测试appA ,需要在模拟器上安装appB 。
Right now everything works if I first install both apps and then run appA tests现在,如果我先安装这两个应用程序然后运行appA测试,一切正常
./gradlew installDebug # install both apps apks
./gradlew connectedInstrumentTest # runs tests on both apps (appB does not have any)
How can I explicitly say that connecedInstrumentTest of appA dependes on installDebug of appB ?我怎么能明确地说appA的connecedInstrumentTest 取决于 appB的installDebug ?
From the parent build.gradle file you can state: 从父build.gradle文件中,您可以声明:
tasks.getByPath(':appA:connectedInstrumentTest').dependsOn(':appB:installDebug') tasks.getByPath( ':的appA:connectedInstrumentTest')。dependsOn( ':程序appB:installDebug')
Or within appA's build.gradle you can add this line: 或者在appA的build.gradle中,您可以添加以下行:
connectedInstrumentTest.dependsOn(':appB:installDebug')
Or an equivalent way to say the same thing in appA's build.gradle: 或者在appA的build.gradle中用同样的方式说同样的事情:
connectedInstrumentTest {
dependsOn: ':appB:installDebug'
}
In module :appA
's build.gradle
add this:在模块:appA
的build.gradle
添加:
afterEvaluate {
tasks.getByName("connectedInstrumentTest") {
dependsOn(":appB:installDebug")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.