Skip to content

Commit 70c171c

Browse files
marko-bekhtayrodiere
authored andcommitted
HHH-19341 Backport JReleaser config to 6.2
1 parent c86816a commit 70c171c

File tree

6 files changed

+33
-93
lines changed

6 files changed

+33
-93
lines changed

build.gradle

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ plugins {
2828
id 'org.checkerframework' version '0.6.34'
2929
id 'org.hibernate.orm.build.jdks'
3030

31-
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
32-
3331
id 'idea'
3432
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.0'
3533
id 'eclipse'
@@ -61,13 +59,6 @@ tasks.register('publish') {
6159
"themselves if they have any publish-related activities to perform"
6260
}
6361

64-
nexusPublishing {
65-
repositories {
66-
sonatype()
67-
}
68-
}
69-
70-
7162
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7263
// CI Build Task
7364

@@ -98,6 +89,3 @@ idea {
9889
name = "hibernate-orm"
9990
}
10091
}
101-
102-
103-

ci/release/Jenkinsfile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ pipeline {
170170
env.RELEASE_VERSION = releaseVersion.toString()
171171
env.DEVELOPMENT_VERSION = developmentVersion.toString()
172172
env.SCRIPT_OPTIONS = params.RELEASE_DRY_RUN ? "-d" : ""
173+
env.JRELEASER_DRY_RUN = params.RELEASE_DRY_RUN
173174

174175
// Determine version id to check if Jira version exists
175176
sh ".release/scripts/determine-jira-version-id.sh ${env.JIRA_KEY} ${releaseVersion.withoutFinalQualifier}"
@@ -191,12 +192,11 @@ pipeline {
191192
// tags the version
192193
// changes the version to the provided development version
193194
withEnv([
194-
"BRANCH=${env.GIT_BRANCH}",
195195
"DISABLE_REMOTE_GRADLE_CACHE=true",
196196
// Increase the amount of memory for this part since asciidoctor doc rendering consumes a lot of metaspace
197197
"GRADLE_OPTS=-Dorg.gradle.jvmargs='-Dlog4j2.disableJmx -Xmx4g -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Duser.language=en -Duser.country=US -Duser.timezone=UTC -Dfile.encoding=UTF-8'"
198198
]) {
199-
sh ".release/scripts/prepare-release.sh ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION}"
199+
sh ".release/scripts/prepare-release.sh -j -b ${env.GIT_BRANCH} -v ${env.DEVELOPMENT_VERSION} ${env.PROJECT} ${env.RELEASE_VERSION}"
200200
}
201201
}
202202
}
@@ -214,20 +214,28 @@ pipeline {
214214
]) {
215215
withCredentials([
216216
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
217-
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'ORG_GRADLE_PROJECT_sonatypePassword', usernameVariable: 'ORG_GRADLE_PROJECT_sonatypeUsername'),
217+
// TODO: HHH-19309:
218+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
219+
// to use the following env variable names to set the user/password:
220+
// - JRELEASER_MAVENCENTRAL_USERNAME
221+
// - JRELEASER_MAVENCENTRAL_TOKEN
222+
// Also use the new `credentialsId` for Maven Central, e.g.:
223+
// usernamePassword(credentialsId: '???????', passwordVariable: 'JRELEASER_MAVENCENTRAL_TOKEN', usernameVariable: 'JRELEASER_MAVENCENTRAL_USERNAME'),
224+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
218225
// https://docs.gradle.org/current/userguide/publishing_gradle_plugins.html#account_setup
219226
usernamePassword(credentialsId: 'gradle-plugin-portal-api-key', passwordVariable: 'GRADLE_PUBLISH_SECRET', usernameVariable: 'GRADLE_PUBLISH_KEY'),
220-
file(credentialsId: 'release.gpg.private-key', variable: 'SIGNING_GPG_PRIVATE_KEY_PATH'),
221-
string(credentialsId: 'release.gpg.passphrase', variable: 'SIGNING_GPG_PASSPHRASE'),
222-
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default')
227+
gitUsernamePassword(credentialsId: 'username-and-token.Hibernate-CI.github.com', gitToolName: 'Default'),
228+
file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
229+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
230+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')
223231
]) {
224232
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
225233
// performs documentation upload and Sonatype release
226234
// push to github
227235
withEnv([
228236
"DISABLE_REMOTE_GRADLE_CACHE=true"
229237
]) {
230-
sh ".release/scripts/publish.sh ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
238+
sh ".release/scripts/publish.sh -j ${env.SCRIPT_OPTIONS} ${env.PROJECT} ${env.RELEASE_VERSION} ${env.DEVELOPMENT_VERSION} ${env.GIT_BRANCH}"
231239
}
232240
}
233241
}

gradle/published-java-module.gradle

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ apply from: rootProject.file( 'gradle/releasable.gradle' )
99
apply from: rootProject.file( 'gradle/java-module.gradle' )
1010
apply from: rootProject.file( 'gradle/publishing-pom.gradle' )
1111

12-
apply plugin: 'signing'
13-
1412
// Make sure that the publishReleaseArtifacts task of the release module runs the release task of this sub module
1513
tasks.getByPath( ':release:publishReleaseArtifacts' ).dependsOn tasks.release
1614

@@ -121,81 +119,20 @@ tasks.withType(PublishToMavenRepository).configureEach {
121119
}
122120
}
123121

124-
125-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126-
// Signing
127-
128-
def signingKey = resolveSigningKey()
129-
def signingPassphrase = resolveSigningPassphrase()
130-
131-
var signingExtension = project.getExtensions().getByType(SigningExtension) as SigningExtension
132-
signingExtension.sign publishing.publications.publishedArtifacts
133-
signingExtension.useInMemoryPgpKeys(signingKey, signingPassphrase)
134-
135-
136-
gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
137-
// are we publishing to OSSRH?
138-
boolean wasPublishingRequested = false
139-
140-
graph.allTasks.each {task ->
141-
if ( task instanceof PublishToMavenRepository ) {
142-
if ( "sonatype" == task.repository.name ) {
143-
wasPublishingRequested = true
144-
}
145-
}
146-
}
147-
148-
if ( wasPublishingRequested ) {
149-
def ossrhUser = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypeUsername" )
150-
def ossrhPass = System.getenv().get( "ORG_GRADLE_PROJECT_sonatypePassword" )
151-
if ( ossrhUser == null || ossrhPass == null ) {
152-
throw new RuntimeException( "Cannot perform publishing to OSSRH without credentials." )
153-
}
154-
logger.lifecycle "Publishing {} : {} : {}", project.group, project.name, project.version
155-
signingExtension.required = true
156-
}
157-
else if ( signingKey == null || signingPassphrase == null ) {
158-
tasks.withType( Sign ).each { t-> t.enabled = false }
159-
}
160-
}
161-
162-
static String resolveSigningKey() {
163-
var key = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY" )
164-
if ( key != null ) {
165-
return key
166-
}
167-
168-
var keyFile = System.getenv().get( "SIGNING_GPG_PRIVATE_KEY_PATH" )
169-
if ( keyFile != null ) {
170-
return new File( keyFile ).text
171-
}
172-
173-
return null
174-
}
175-
176-
static String resolveSigningPassphrase() {
177-
return System.getenv().get( "SIGNING_GPG_PASSPHRASE" )
178-
}
179-
180-
181122
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182123
// Release / publishing tasks
183124

184125
tasks.register('ciBuild') {
185-
dependsOn test, tasks.publishToSonatype
126+
dependsOn test
186127
}
187128

188-
tasks.release.dependsOn tasks.test, tasks.publishToSonatype
129+
tasks.release.dependsOn tasks.test
189130

190131
tasks.preVerifyRelease.dependsOn build
191132
tasks.preVerifyRelease.dependsOn generateMetadataFileForPublishedArtifactsPublication
192133
tasks.preVerifyRelease.dependsOn generatePomFileForPublishedArtifactsPublication
193134
tasks.preVerifyRelease.dependsOn generatePomFileForRelocationPomPublication
194135

195-
tasks.publishToSonatype.mustRunAfter test
196-
197-
198-
199136
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
200137
// Ancillary tasks
201138

gradle/publishing-pom.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,18 @@ publishing {
5959

6060
}
6161
}
62+
repositories {
63+
maven {
64+
name = "staging"
65+
url = rootProject.layout.buildDirectory.dir("staging-deploy${File.separator}maven")
66+
}
67+
maven {
68+
name = 'snapshots'
69+
url = "https://oss.sonatype.org/content/repositories/snapshots/"
70+
// So that Gradle uses the `ORG_GRADLE_PROJECT_snapshotsPassword` / `ORG_GRADLE_PROJECT_snapshotsUsername`
71+
// env variables to read the username/password for the `snapshots` repository publishing:
72+
credentials(PasswordCredentials)
73+
}
74+
}
6275

6376
}

hibernate-platform/hibernate-platform.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,3 @@ publishing {
7575
}
7676
}
7777
}
78-
79-
project( ":release" ).getTasks().named( "publishReleaseArtifacts" ).configure {
80-
dependsOn tasks.release
81-
}
82-
83-
tasks.release.dependsOn tasks.publishToSonatype

tooling/hibernate-gradle-plugin/hibernate-gradle-plugin.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ gradle.taskGraph.whenReady { tg ->
170170
if ( t.repository == null ) {
171171
logger.info( "Task `{}` had null repository", t.path )
172172
}
173-
else if ( t.repository.name == "sonatype" ) {
174-
logger.debug( "Disabling task `{}` because it publishes to Sonatype", t.path )
173+
else if ( t.repository.name == "staging" || t.repository.name == "snapshots" ) {
174+
logger.debug( "Disabling task `{}` because it publishes to remote Maven repository", t.path )
175175
t.enabled = false
176176
}
177177
}
178-
}
178+
}

0 commit comments

Comments
 (0)