Created
October 13, 2018 04:02
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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