Skip to content

Instantly share code, notes, and snippets.

@Krillsson
Created December 22, 2022 11:47
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 Krillsson/62654d5db87e636d68aeb7a8d5b60d3b to your computer and use it in GitHub Desktop.
Save Krillsson/62654d5db87e636d68aeb7a8d5b60d3b to your computer and use it in GitHub Desktop.
Safely read properties in Gradle
static def readProperty(propertiesFile, key, defaultValue){
def properties = new Properties()
if (propertiesFile.canRead()) {
properties.load(propertiesFile.newDataInputStream())
properties.get(key, defaultValue)
} else {
defaultValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment