Slackbot
03/06/2023, 11:21 AMDaymon
03/11/2023, 4:38 AMandroid should be available at compile time, unless you're referring to productFlavors not being populated? The problem is that product flavors can be declared arbitrarily around one's build; maybe in a plugin, maybe in an obscure build script. To do some computation on the productFlavors you should use the .all method:
task decideWhichTestToRun() {
  android.productFlavors.all {
    // ...
  }
}
Although that doesn't fit your use case. tbcf, your use case may be an edge case. You could do something like this:
task decideWhichTestToRun() {
  afterEvaluate {
    // ...
  }
}
But that generally indicates a design error. Ideally you would have tests that always run- and then tests that also run if under a certain flavor.