Created
December 22, 2022 11:47
-
-
Save Krillsson/62654d5db87e636d68aeb7a8d5b60d3b to your computer and use it in GitHub Desktop.
Safely read properties in Gradle
This file contains 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
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