Skip to content

Instantly share code, notes, and snippets.

@danielsanfr
Created October 13, 2018 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielsanfr/245a479b3815af817a2656ecaaebda7c to your computer and use it in GitHub Desktop.
Save danielsanfr/245a479b3815af817a2656ecaaebda7c to your computer and use it in GitHub Desktop.
Load all .env files in the project's root directory on project property
task loadEnv(dependsOn: ":app:build") {
file(rootProject.projectDir).listFiles({
it.isFile() && it.name.endsWith(".env")
} as FileFilter).each { file ->
file.withInputStream { inputStream ->
def properties = new Properties()
properties.load(inputStream)
properties.stringPropertyNames().forEach { name ->
ext.setProperty(name, properties.getProperty(name))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment