From a39bf55a653c3a55e72b012d965b05898c2ad538 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 25 Apr 2022 09:08:23 -0500 Subject: [PATCH] HHH-15236 - Fix signing of published artifacts --- build.gradle | 1 - gradle/published-java-module.gradle | 40 ++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 763b3765ba..7ea34864fd 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,6 @@ buildscript { dependencies { classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'de.thetaphi:forbiddenapis:3.2' classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1' } diff --git a/gradle/published-java-module.gradle b/gradle/published-java-module.gradle index 81c4540212..675e1cb2c0 100644 --- a/gradle/published-java-module.gradle +++ b/gradle/published-java-module.gradle @@ -97,22 +97,48 @@ publishing { } signing { - required { !rootProject.ormVersion.isSnapshot && gradle.taskGraph.hasTask("publish") } - - def signingKey = findProperty('signingKey') - def signingPassword = findProperty('signingPassword') - - useInMemoryPgpKeys(signingKey, signingPassword) + var signingKey = resolveSigningKey() + var signingPassword = findSigningProperty( "signingPassword" ) + useInMemoryPgpKeys( signingKey, signingPassword ) sign publishing.publications.publishedArtifacts } +String resolveSigningKey() { + var key = findSigningProperty( "signingKey" ) + if ( key != null ) { + return key + } + + var keyFile = findSigningProperty( "signingKeyFile" ) + if ( keyFile != null ) { + return new File( keyFile ).text + } + + return null +} + +String findSigningProperty(String propName) { + if ( System.getProperty(propName ) != null ) { + logger.lifecycle "Found `{}` as a system property", propName + return System.getProperty(propName ) + } + else if ( project.hasProperty( propName ) ) { + logger.lifecycle "Found `{}` as a project property", propName + return project.hasProperty( propName ) + } + else { + logger.lifecycle "Did not find `{}`", propName + return null + } +} + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Release / publishing tasks task ciBuild { - dependsOn test, publish + dependsOn test, publishToSonatype } tasks.release.dependsOn tasks.test, tasks.publishToSonatype