Last active
November 3, 2016 17:40
-
-
Save NomenSvyat/ff585d3c063c2fae4eacf3d763ce4a46 to your computer and use it in GitHub Desktop.
Getting passwords for signing from file or environment
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 askForPasswords << { | |
def storePass | |
def keyAlias | |
def keyPass | |
def keystorePropertiesFile = new File("../keystore/keystore.properties") | |
println keystorePropertiesFile.absolutePath | |
if (keystorePropertiesFile.exists()) { | |
println "Loading keystore passwords from property file..." | |
Properties properties = new Properties() | |
properties.load(new FileInputStream(keystorePropertiesFile)) | |
println properties.getProperty('keyAlias') | |
storePass = properties['storePassword'] | |
keyAlias = properties['keyAlias'] | |
keyPass = properties['keyPassword'] | |
} else if (System.getenv("KEY_ALIAS") != null) { | |
println "Getting keystore passwords from environment variables..." | |
storePass = System.getenv("STORE_PASS") | |
keyAlias = System.getenv("KEY_ALIAS") | |
keyPass = System.getenv("KEY_PASS") | |
} | |
android.signingConfigs.release.storePassword = storePass | |
android.signingConfigs.release.keyAlias = keyAlias | |
android.signingConfigs.release.keyPassword = keyPass | |
} | |
tasks.whenTaskAdded { | |
theTask -> | |
if (theTask.name.matches("package.*Release")) { | |
theTask.dependsOn "askForPasswords" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment