Skip to content

Instantly share code, notes, and snippets.

@dekalo-stanislav
Last active November 19, 2018 21:30
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 dekalo-stanislav/b8cdc609c150ef42523e600cb59d481d to your computer and use it in GitHub Desktop.
Save dekalo-stanislav/b8cdc609c150ef42523e600cb59d481d to your computer and use it in GitHub Desktop.
Easy and secure way to provide release keystore and password to gradle
/**
* Here you may define you PC local way to obtain passwords.
*/
ext {
def localPropertiesFile = project.rootProject.file('local.properties');
Properties localProperties = new Properties()
if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.newDataInputStream())
}
/**
* We will look required variable in local.properties, system environment and in command line properties.
*/
getValue = { name ->
def result = localProperties.getProperty(name)
if (result == null) result = System.getenv(name)
if (result == null && getRootProject().hasProperty(name)) result = getRootProject().getProperty(name)
if (result == null) result = "NO_SUCH_PROPERTY"
return result
}
/**
* Release related variables
*/
getAppKeyStorePassword = {
return getValue('APP_KEYSTORE_PASSWORD')
}
getAppKeyPassword = {
return getValue('APP_KEY_PASSWORD')
}
/**
* You may extends with additional paramters.
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment