From 1a18813c46f0294f9b03eadf2484e51f41254d04 Mon Sep 17 00:00:00 2001 From: Andrew Oberstar Date: Sat, 17 Feb 2024 22:19:02 -0600 Subject: [PATCH] Use subkeys for signing Requires specifying the key ID. --- build.gradle.kts | 3 ++- .../gradle/defaults/MavenCentralConventionPlugin.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3348575..70f298b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -122,9 +122,10 @@ publishing { signing { setRequired(providers.environmentVariable("CI").orNull) + val signingKeyId: String? by project val signingKey: String? by project val signingPassphrase: String? by project - useInMemoryPgpKeys(signingKey, signingPassphrase) + useInMemoryPgpKeys(signingKeyId, signingKey, signingPassphrase) sign(publishing.publications) } diff --git a/src/main/java/org/ajoberstar/gradle/defaults/MavenCentralConventionPlugin.java b/src/main/java/org/ajoberstar/gradle/defaults/MavenCentralConventionPlugin.java index 25043ef..ce2c063 100644 --- a/src/main/java/org/ajoberstar/gradle/defaults/MavenCentralConventionPlugin.java +++ b/src/main/java/org/ajoberstar/gradle/defaults/MavenCentralConventionPlugin.java @@ -91,11 +91,12 @@ private void configurePom(Project project, PublishingExtension publishing, Maven private void enableSigning(Project project, SigningExtension signing, PublishingExtension publishing) { var isCi = project.getProviders().environmentVariable("CI"); + var signingKeyId = project.getProviders().gradleProperty("signingKeyId"); var signingKey = project.getProviders().gradleProperty("signingKey"); var signingPassphrase = project.getProviders().gradleProperty("signingPassphrase"); signing.setRequired(isCi.getOrNull()); - signing.useInMemoryPgpKeys(signingKey.getOrNull(), signingPassphrase.getOrNull()); + signing.useInMemoryPgpKeys(signingKeyId.getOrNull(), signingKey.getOrNull(), signingPassphrase.getOrNull()); signing.sign(publishing.getPublications()); } }