react-native-config/android/dotenv.gradle

21 lines
453 B
Groovy
Raw Normal View History

def readDotEnv = {
def env = [:]
2016-02-24 00:07:24 +00:00
def envFile = System.env['ENVFILE'] ?: "$project.rootDir/../.env"
new File(envFile).eachLine { line ->
def (key, val) = line.tokenize('=')
if (key && val) {
env.put(key, val)
}
}
env
}
android {
defaultConfig {
readDotEnv().each { k, v ->
buildConfigField "String", k, "\"$v\""
resValue "string", k, "\"$v\""
}
}
}