2016-02-22 16:18:50 -08:00
|
|
|
def readDotEnv = {
|
|
|
|
def env = [:]
|
2016-03-03 13:32:32 -08:00
|
|
|
def envFile = System.env['ENVFILE'] ?: ".env"
|
2016-02-23 16:25:35 -08:00
|
|
|
println("Reading env from: $envFile")
|
2016-03-03 13:32:32 -08:00
|
|
|
new File("$project.rootDir/../$envFile").eachLine { line ->
|
2016-02-22 16:18:50 -08:00
|
|
|
def (key, val) = line.tokenize('=')
|
|
|
|
if (key && val) {
|
|
|
|
env.put(key, val)
|
|
|
|
}
|
|
|
|
}
|
2016-02-23 16:25:35 -08:00
|
|
|
project.ext.set("env", env)
|
2016-02-22 16:18:50 -08:00
|
|
|
}
|
|
|
|
|
2016-02-23 16:25:35 -08:00
|
|
|
readDotEnv()
|
|
|
|
|
2016-02-22 16:18:50 -08:00
|
|
|
android {
|
|
|
|
defaultConfig {
|
2016-02-23 16:25:35 -08:00
|
|
|
project.env.each { k, v ->
|
2016-02-22 16:18:50 -08:00
|
|
|
buildConfigField "String", k, "\"$v\""
|
|
|
|
resValue "string", k, "\"$v\""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|