Skip to content

Instantly share code, notes, and snippets.

@aconstantin
Created September 14, 2013 16:27
Show Gist options
  • Save aconstantin/6563364 to your computer and use it in GitHub Desktop.
Save aconstantin/6563364 to your computer and use it in GitHub Desktop.
Getting Input from Console in Gradle Build
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