I try to convert this to Kotlin:
applicationVariants.all { variant ->
def flavor = variant.productFlavors[0]
def mergedFlavor = variant.getMergedFlavor()
mergedFlavor.manifestPlaceholders = [applicationLabel: "${variant.buildType.appName[flavor.name]}"]
}
But the manifestPlaceholder is a val and cannot be reassigned, so this results in an error:
applicationVariants.forEach {variant->
val flavor = variant.productFlavors[0]
val mergedFlavor = variant.mergedFlavor
variant.mergedFlavor.manifestPlaceholders = mapOf("applicationLabel" to "${variant.buildType.appName[flavor.name]}")
}
Normally I could set this in the buildTypes closure, but I cannot do it here, because appName is a map in the buildTypes, where the key is the flavor name, so the applicationLabel depends both on the build type and the flavor. And I think you cannot access the flavors in the buildTypes, that's why you need applicationVariants.