Skip to content

Commit 4012fa8

Browse files
committed
Use jreleaser for maven central publication (#1267)
Fixes #923 _ Conflicts: _ build.gradle _ gitlab4j-api/build.gradle _ gitlab4j-models/build.gradle
1 parent fe43ec3 commit 4012fa8

File tree

1 file changed

+68
-34
lines changed

1 file changed

+68
-34
lines changed

build.gradle

Lines changed: 68 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
plugins {
33
id 'java-library'
44
id 'com.diffplug.spotless' version '6.2.0'
5-
id 'signing'
65
id 'maven-publish'
7-
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
8-
id 'net.researchgate.release' version '3.0.2'
6+
id 'org.jreleaser' version '1.19.0'
7+
id 'net.researchgate.release' version '3.1.0'
98
}
109

1110
wrapper {
1211
gradleVersion = '8.10.1'
1312
}
1413

15-
group = 'org.gitlab4j'
14+
String groupId = 'org.gitlab4j'
15+
group = groupId
16+
17+
def repositoryPath = 'build/staging-deploy'
1618

1719
dependencies {
1820
api 'jakarta.activation:jakarta.activation-api:1.2.2'
@@ -30,17 +32,6 @@ dependencies {
3032
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.10.4"
3133
}
3234

33-
signing {
34-
useGpgCmd()
35-
sign(publishing.publications)
36-
}
37-
38-
tasks.withType(Sign) {
39-
onlyIf {
40-
project.hasProperty('signing.gnupg.keyName')
41-
}
42-
}
43-
4435
java {
4536
withJavadocJar()
4637
withSourcesJar()
@@ -67,13 +58,53 @@ spotless {
6758
}
6859
}
6960

70-
nexusPublishing {
71-
packageGroup = 'org.gitlab4j'
72-
repositories {
73-
sonatype {
74-
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
75-
username = project.findProperty('ossSonatypeUsername') ?: ''
76-
password = project.findProperty('ossSonatypePassword') ?: ''
61+
jreleaser {
62+
signing {
63+
active = 'RELEASE'
64+
armored = true
65+
}
66+
deploy {
67+
maven {
68+
mavenCentral {
69+
gitlab4j {
70+
active = 'RELEASE'
71+
namespace = 'org.gitlab4j'
72+
url = 'https://central.sonatype.com/api/v1/publisher'
73+
stagingRepository(repositoryPath)
74+
retryDelay = 30
75+
maxRetries = 150
76+
}
77+
}
78+
}
79+
}
80+
release {
81+
github {
82+
enabled = true
83+
repoOwner = "$githubRepositoryOwner"
84+
name = "$githubRepositoryName"
85+
tagName = '{{projectVersion}}'
86+
overwrite = true
87+
skipTag = true
88+
releaseNotes {
89+
enabled = true
90+
}
91+
changelog {
92+
enabled = false
93+
}
94+
milestone {
95+
close = true
96+
}
97+
issues {
98+
enabled = true
99+
comment = 'This issue has been resolved in `{{tagName}}` ([Release Notes]({{releaseNotesUrl}}))'
100+
applyMilestone = 'ALWAYS'
101+
102+
label {
103+
name = 'released'
104+
color = '#FF0000'
105+
description = 'Issue has been released'
106+
}
107+
}
77108
}
78109
}
79110
}
@@ -106,6 +137,7 @@ publishing {
106137
}
107138
developer {
108139
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
140+
id = "$githubRepositoryOwner"
109141
}
110142
}
111143
scm {
@@ -117,12 +149,24 @@ publishing {
117149
from components.java
118150
}
119151
}
152+
publishing {
153+
repositories {
154+
maven {
155+
url = rootProject.file(repositoryPath)
156+
}
157+
}
158+
}
120159
}
121160

122161
release {
123-
buildTasks = ['doRelease']
162+
buildTasks = [
163+
'checkLastVersionValue',
164+
'clean',
165+
'publish',
166+
'jreleaserDeploy'
167+
]
124168
git {
125-
requireBranch.set('main')
169+
requireBranch.set('5.x.x')
126170
}
127171
}
128172

@@ -147,16 +191,6 @@ def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
147191
}
148192
}
149193

150-
tasks.register('doRelease') {
151-
dependsOn(
152-
checkLastVersionValueTask,
153-
'initializeSonatypeStagingRepository',
154-
'clean',
155-
'build',
156-
project.getTasksByName('publishToSonatype', true)
157-
)
158-
}
159-
160194
model {
161195
tasks.unSnapshotVersion {
162196
dependsOn updateLastVersionValueTask

0 commit comments

Comments
 (0)