Created
December 25, 2017 14:15
-
-
Save nkraev/fface9db5c036f114609bbabb8800618 to your computer and use it in GitHub Desktop.
Variant-aware gradle configuration for replacing manifest 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