HHH-15236 - Fix signing of published artifacts

This commit is contained in:
Steve Ebersole 2022-04-25 09:08:23 -05:00
parent a2e39a1757
commit a39bf55a65
2 changed files with 33 additions and 8 deletions

View File

@ -13,7 +13,6 @@ buildscript {
dependencies { dependencies {
classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0' classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7' 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 'de.thetaphi:forbiddenapis:3.2'
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1' classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.1'
} }

View File

@ -97,22 +97,48 @@ publishing {
} }
signing { signing {
required { !rootProject.ormVersion.isSnapshot && gradle.taskGraph.hasTask("publish") } var signingKey = resolveSigningKey()
var signingPassword = findSigningProperty( "signingPassword" )
def signingKey = findProperty('signingKey') useInMemoryPgpKeys( signingKey, signingPassword )
def signingPassword = findProperty('signingPassword')
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.publishedArtifacts 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 // Release / publishing tasks
task ciBuild { task ciBuild {
dependsOn test, publish dependsOn test, publishToSonatype
} }
tasks.release.dependsOn tasks.test, tasks.publishToSonatype tasks.release.dependsOn tasks.test, tasks.publishToSonatype