Skip to content

Commit aaac86e

Browse files
committed
read signing parameters from the console
Because putting the passphrase in a file is just plain unacceptable and putting it on the command line makes it visible to everyone else on the machine in addition (depending on the environment). The code snipped has just been copied verbatim from http://gradle.org/docs/current/userguide/signing_plugin.html.
1 parent c576a73 commit aaac86e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Diff for: build.gradle

+23
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,26 @@ subprojects {
132132
uploadArchives.enabled = false
133133
}
134134
}
135+
136+
import org.gradle.plugins.signing.Sign
137+
138+
gradle.taskGraph.whenReady { taskGraph ->
139+
if (taskGraph.allTasks.any { it instanceof Sign }) {
140+
// Use Java 6's console to read from the console (no good for
141+
// a CI environment)
142+
Console console = System.console()
143+
console.printf "\n\nWe have to sign some things in this build." +
144+
"\n\nPlease enter your signing details.\n\n"
145+
146+
def id = console.readLine("PGP Key Id: ")
147+
def file = console.readLine("PGP Secret Key Ring File (absolute path): ")
148+
def password = console.readPassword("PGP Private Key Password: ")
149+
150+
allprojects { ext."signing.keyId" = id }
151+
allprojects { ext."signing.secretKeyRingFile" = file }
152+
allprojects { ext."signing.password" = password }
153+
154+
console.printf "\nThanks.\n\n"
155+
}
156+
}
157+

0 commit comments

Comments
 (0)