Created
December 25, 2017 14:13
-
-
Save anonymous/3e75afb56c573ed53c61a5d1e4d043f8 to your computer and use it in GitHub Desktop.
Variant-aware configuration for replacing strings in manifest (as placeholders) and resources
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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