Traditionally, in Groovy, it was possible to define flavor-specific variables in the ext
{}
block, but switching to Kotlin DSL it seems that the extra
map has the project scope.
It looks like it is possible to force a flavor scope for extras by using:
productFlavors {
register("flavor1") {
require(this is ExtensionAware)
...
}
register("flavor2") {
require(this is ExtensionAware)
...
}
}
(source: https://github.com/gradle/kotlin-dsl-samples/issues/1254)
But if it needs to be used later, for example to tweak the variables based on buildType
like this:
variants.forEach { variant ->
val flavor = variant.productFlavors[0]
val size = ?? // extra??
variant.buildConfigField("String", "SIZE", size)
}
how would these flavor-scoped references to extra
be used?