Skip to content

Commit 49e108b

Browse files
authored
Use jreleaser for maven central publication (#1267)
Fixes #923
1 parent 2d92f1a commit 49e108b

File tree

3 files changed

+66
-38
lines changed

3 files changed

+66
-38
lines changed

build.gradle

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
id 'com.diffplug.spotless' version '6.25.0' apply false
33
id 'org.kordamp.gradle.jandex' version '2.1.0' apply false
4-
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
4+
id 'org.jreleaser' version '1.19.0'
55
id 'net.researchgate.release' version '3.1.0'
66
}
77

@@ -10,27 +10,17 @@ wrapper {
1010
}
1111

1212
String groupId = 'org.gitlab4j'
13+
group = groupId
1314

15+
def repositoryPath = 'build/staging-deploy'
1416
subprojects {
1517
apply plugin: 'java-library'
16-
apply plugin: 'signing'
1718
apply plugin: 'com.diffplug.spotless'
1819
apply plugin: 'maven-publish'
1920
apply plugin: 'org.kordamp.gradle.jandex'
2021

2122
group = groupId
2223

23-
signing {
24-
useGpgCmd()
25-
sign(publishing.publications)
26-
}
27-
28-
tasks.withType(Sign) {
29-
onlyIf {
30-
project.hasProperty('signing.gnupg.keyName')
31-
}
32-
}
33-
3424
java {
3525
withJavadocJar()
3626
withSourcesJar()
@@ -61,21 +51,74 @@ subprojects {
6151
tasks.named("javadoc") {
6252
inputs.files(tasks.getByPath("jandex").outputs.files)
6353
}
54+
55+
publishing {
56+
repositories {
57+
maven {
58+
url = rootProject.file(repositoryPath)
59+
}
60+
}
61+
}
6462
}
6563

66-
nexusPublishing {
67-
packageGroup = 'org.gitlab4j'
68-
repositories {
69-
sonatype {
70-
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
71-
username = project.findProperty('ossSonatypeUsername') ?: ''
72-
password = project.findProperty('ossSonatypePassword') ?: ''
64+
jreleaser {
65+
signing {
66+
active = 'RELEASE'
67+
armored = true
68+
}
69+
deploy {
70+
maven {
71+
mavenCentral {
72+
gitlab4j {
73+
active = 'RELEASE'
74+
namespace = 'org.gitlab4j'
75+
url = 'https://central.sonatype.com/api/v1/publisher'
76+
stagingRepository(repositoryPath)
77+
retryDelay = 30
78+
maxRetries = 150
79+
}
80+
}
81+
}
82+
}
83+
release {
84+
github {
85+
enabled = true
86+
repoOwner = "$githubRepositoryOwner"
87+
name = "$githubRepositoryName"
88+
tagName = '{{projectVersion}}'
89+
overwrite = true
90+
skipTag = true
91+
releaseNotes {
92+
enabled = true
93+
}
94+
changelog {
95+
enabled = false
96+
}
97+
milestone {
98+
close = true
99+
}
100+
issues {
101+
enabled = true
102+
comment = 'This issue has been resolved in `{{tagName}}` ([Release Notes]({{releaseNotesUrl}}))'
103+
applyMilestone = 'ALWAYS'
104+
105+
label {
106+
name = 'released'
107+
color = '#FF0000'
108+
description = 'Issue has been released'
109+
}
110+
}
73111
}
74112
}
75113
}
76114

77115
release {
78-
buildTasks = ['doRelease']
116+
buildTasks = [
117+
'checkLastVersionValue',
118+
'clean',
119+
'publish',
120+
'jreleaserDeploy'
121+
]
79122
git {
80123
requireBranch.set('main')
81124
}
@@ -107,25 +150,8 @@ def updateLastVersionValueTask = tasks.register('updateLastVersionValue') {
107150
}
108151
}
109152

110-
task doRelease {
111-
dependsOn(
112-
checkLastVersionValueTask,
113-
'initializeSonatypeStagingRepository',
114-
'clean',
115-
'build'
116-
)
117-
}
118-
119153
model {
120154
tasks.unSnapshotVersion {
121155
dependsOn updateLastVersionValueTask
122156
}
123157
}
124-
// dependency on 'publishToSonatype' must be added in a 'afterEvaluate' block, see https://github.com/gradle/gradle/issues/16543#issuecomment-2529428010
125-
afterEvaluate {
126-
model {
127-
tasks.doRelease {
128-
dependsOn project.getTasksByName('publishToSonatype', true)
129-
}
130-
}
131-
}

gitlab4j-api/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ publishing {
4242
email = 'gautier@jabby-techs.fr'
4343
}
4444
developer {
45+
id = "$githubRepositoryOwner"
4546
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
4647
}
4748
}

gitlab4j-models/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ publishing {
3636
email = 'gautier@jabby-techs.fr'
3737
}
3838
developer {
39+
id = "$githubRepositoryOwner"
3940
url = 'https://github.com/orgs/' + "$githubRepositoryOwner" + '/people'
4041
}
4142
}

0 commit comments

Comments
 (0)