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