1 min readJun 30, 2018
If I got you right, you can do smth like this:
First, create tasks as it was mentioned in productFlavors section:
all { flavor ->
task("doSomething${flavor.name.capitalize()}") {
doLast {
println "doSomething${flavor.name.capitalize()}"
}
}
}
Then add this code to the end of the build.gradle file:
afterEvaluate {
android.productFlavors.all { flavor ->
tasks."assemble${flavor.name.capitalize()}Debug".dependsOn "doSomething${flavor.name.capitalize()}"
}
}
In this case every assembleFlavorDebug task will depend on the corresponding doSomethingFlavor task.