mirror of
https://github.com/status-im/react-native-config.git
synced 2025-02-24 12:58:10 +00:00
Resource strings cannot include `%` as-is (cf. http://stackoverflow.com/questions/4414389/android-xml-percent-symbol).
25 lines
627 B
Groovy
25 lines
627 B
Groovy
def readDotEnv = {
|
|
def env = [:]
|
|
def envFile = System.env['ENVFILE'] ?: ".env"
|
|
println("Reading env from: $envFile")
|
|
new File("$project.rootDir/../$envFile").eachLine { line ->
|
|
def (key, val) = line.tokenize('=')
|
|
if (key && val && key.substring(0, 1) != "#") {
|
|
env.put(key, val)
|
|
}
|
|
}
|
|
project.ext.set("env", env)
|
|
}
|
|
|
|
readDotEnv()
|
|
|
|
android {
|
|
defaultConfig {
|
|
project.env.each { k, v ->
|
|
def escaped = v.replaceAll("%","\\\\u0025")
|
|
buildConfigField "String", k, "\"$v\""
|
|
resValue "string", k, "\"$escaped\""
|
|
}
|
|
}
|
|
}
|