Created
September 14, 2013 16:27
-
-
Save aconstantin/6563364 to your computer and use it in GitHub Desktop.
Getting Input from Console in Gradle Build
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
import org.gradle.plugins.signing.Sign | |
gradle.taskGraph.whenReady { taskGraph -> | |
if (taskGraph.allTasks.any { it instanceof Sign }) { | |
// Use Java 6's console to read from the console (no good for a CI environment) | |
Console console = System.console() | |
console.printf "\n\nWe have to sign some things in this build.\n\nPlease enter your signing details.\n\n" | |
def id = console.readLine("PGP Key Id: ") | |
def file = console.readLine("PGP Secret Key Ring File (absolute path): ") | |
def password = console.readPassword("PGP Private Key Password: ") | |
allprojects { ext."signing.keyId" = id } | |
allprojects { ext."signing.secretKeyRingFile" = file } | |
allprojects { ext."signing.password" = password } | |
console.printf "\nThanks.\n\n" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment