Skip to content

Instantly share code, notes, and snippets.

@SelvinPL
Last active March 25, 2024 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SelvinPL/0cf9e0ddce3b1778a9b8bd001f1ce53c to your computer and use it in GitHub Desktop.
Save SelvinPL/0cf9e0ddce3b1778a9b8bd001f1ce53c to your computer and use it in GitHub Desktop.
class PropExtension extends Closure {
final map = [:]
PropExtension() {
super(null)
}
def methodMissing(String name, args) {
map[name] = args[0]
}
}
android {
productFlavors.configureEach { flavour ->
flavour.extensions.create("customProperties", PropExtension)
}
}
android.applicationVariants.configureEach { variant ->
var map = variant.productFlavors.find({ it.dimension == 'other' }).extensions.customProperties.map
//do something based on map
println map
}
android {
flavorDimensions = ['other']
//....
productFlavors {
flavorA {
dimension "other"
customProperties {
propertyB "property2"
}
}
flavorB {
dimension "other"
customProperties {
propertyA "property1bis"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment