Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle task of project depend on task of other project

Tags:

android

gradle

I have an android project with two different apps.

This is my current structure:

appA/
  buid.gradle
  ...
appB/
  buid.gradle
  ...
settings.gradle
gradlew

settings.gradle is the following:

include ':appA'
include ':appB'

To test appA, appB needs to be installed on the emulator.

Right now everything works if I first install both apps and then run appA tests

./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?

like image 783
Joao Trindade Avatar asked Feb 16 '14 14:02

Joao Trindade


1 Answers

From the parent build.gradle file you can state:

tasks.getByPath(':appA:connectedInstrumentTest').dependsOn(':appB:installDebug')

Or within appA's build.gradle you can add this line:

connectedInstrumentTest.dependsOn(':appB:installDebug')

Or an equivalent way to say the same thing in appA's build.gradle:

connectedInstrumentTest {
   dependsOn: ':appB:installDebug'
}
like image 103
ditkin Avatar answered Nov 02 '22 19:11

ditkin