Last active
November 19, 2018 21:30
-
-
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
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
/** | |
* 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