Skip to content

Instantly share code, notes, and snippets.

Created December 25, 2017 14:13
Show Gist options
  • Save anonymous/3e75afb56c573ed53c61a5d1e4d043f8 to your computer and use it in GitHub Desktop.
Save anonymous/3e75afb56c573ed53c61a5d1e4d043f8 to your computer and use it in GitHub Desktop.
Variant-aware configuration for replacing strings in manifest (as placeholders) and resources
android.applicationVariants.all { variant ->
String propsName = "../local/${variant.baseName}.properties"
Properties props = new Properties()
props.load(new FileInputStream(file(propsName)))
println "Building \"${variant.baseName}\" tag..."
props.stringPropertyNames().forEach {
variant.resValue("string", it, props[it])
}
props = new Properties()
String manifestName = "../local/manifest-${variant.baseName}.properties"
props.load(new FileInputStream(file(manifestName)))
def manifest = [:]
props.stringPropertyNames().forEach { manifest[it] = props[it] }
variant.mergedFlavor.manifestPlaceholders = manifest
println "Properties generated!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment