Repository: incubator-edgent Updated Branches: refs/heads/master b214477b1 -> b3248718a
Add 'signAll' task Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/a2d8f1cb Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/a2d8f1cb Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/a2d8f1cb Branch: refs/heads/master Commit: a2d8f1cb74808d1cd957ba63132445fd3dd756b7 Parents: df0d384 Author: Dale LaBossiere <[email protected]> Authored: Wed Oct 12 10:10:00 2016 -0400 Committer: Dale LaBossiere <[email protected]> Committed: Wed Oct 12 10:11:48 2016 -0400 ---------------------------------------------------------------------- build.gradle | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/a2d8f1cb/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index 0056f4f..b94d50a 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,9 @@ defaultTasks 'assemble' apply from: 'other.gradle' + +import org.gradle.plugins.signing.Sign +import java.io.Console /* Configure root project */ allprojects { @@ -97,6 +100,10 @@ ext { samples_ext_dependencies, // test_common_dependencies, // omit as tests aren't included in release tgz ].flatten() + + ext."signing.keyId" = null + ext."signing.secretKeyRingFile" = null + ext."signing.password" = null } // Declare the common_ext_dependencies as dependencies of the root project @@ -743,10 +750,56 @@ task srcReleaseTarGz(type: Tar) { } } -signing { -// creates circular dep... :assemble -> :signReleaseTgz -> :releaseTarGz -> :assemble -// sign srcReleaseTarGz // creates task signSrcReleaseTarGz -// sign releaseTarGz // creates task signReleaseTarGz +gradle.taskGraph.whenReady { taskGraph -> + if (ext."signing.password"==null && taskGraph.allTasks.any { it instanceof Sign }) { + // Use Java console to read from the console (no good for a CI environment) + def Console console = System.console() + console.printf "\n\n#####################################" + + "\nWe have to sign some things in this build." + + "\nPlease enter your signing details.\n\n" + def id = System.env['GPG_ID'] + try { + def tmpId = console.readLine("PGP Code Signing Key Id (default: $id): ") + if (!tmpId.isEmpty()) + id = tmpId + } catch (NullPointerException e) { + throw new GradleException("You must run 'signAll --no-daemon'") + } + def file = System.env['GPG_SECRING'] + if (file == null) { + file = "${System.properties['user.home']}/.gnupg/secring.gpg" + } + def tmpFile = console.readLine("PGP Secret Key Ring File (default: $file): ") + if (!tmpFile.isEmpty()) { + file = tmpFile + } + def password = String.valueOf(console.readPassword("PGP Private Key Password: ")) + + allprojects { ext."signing.keyId" = id } + allprojects { ext."signing.secretKeyRingFile" = file } + allprojects { ext."signing.password" = password } + + console.printf "\n#####################################\n" + } +} + +task signAll(type: Sign) { + description='Sign existing release artifacts in ${target_dir}/../release-edgent (run separetely after "release")' + fileTree("${target_dir}/../release-edgent") { + include '**/*.tgz' + }.each { + sign it + } + outputs.upToDateWhen { false } + doFirst { + if (getFilesToSign().isEmpty()) { + throw new GradleException("No artifacts to sign. Run the 'release' task first.") + } + //println "### files to sign: " + getFilesToSign().collect { it.name }.join(",") + } + doLast { + println "\nCreated signature files: " + getSignatureFiles().collect { it.name }.join(", ") + } } assemble {
