1+ import org.jreleaser.model.Active
2+
13plugins {
24 id(" java-library" )
35 id(" checkstyle" )
4- alias(libs.plugins.maven.publish)
6+ id(" maven-publish" )
7+ alias(libs.plugins.jreleaser)
58}
69
710group = " org.komamitsu"
1215 toolchain {
1316 languageVersion = JavaLanguageVersion .of(17 )
1417 }
18+ withJavadocJar()
19+ withSourcesJar()
1520}
1621
1722repositories {
@@ -31,7 +36,7 @@ dependencies {
3136// PackageVersion.java carries the coordinates and version Jackson reports via Versioned.
3237// Generate it from the Gradle project so it cannot drift from the published POM.
3338val packageDir = " org/komamitsu/jackson/dataformat/msgpack"
34- val generatePackageVersion by tasks.registering {
39+ val generatePackageVersion = tasks.register( " generatePackageVersion " ) {
3540 val outputDir = layout.buildDirectory.dir(" generated/sources/packageVersion/java/main" )
3641 val projectVersion = project.version.toString()
3742 val projectGroup = project.group.toString()
@@ -128,32 +133,63 @@ checkstyle {
128133 maxWarnings = 0
129134}
130135
131- mavenPublishing {
132- publishToMavenCentral()
133- signAllPublications()
134-
135- pom {
136- name = project.name
137- description = project.description
138- url = " https://github.com/komamitsu/jackson-dataformat-msgpack"
139- licenses {
140- license {
141- name = " Apache-2.0"
142- url = " https://www.apache.org/licenses/LICENSE-2.0.txt"
136+ // Publications are staged locally; JReleaser signs them and uploads them to the Central Portal.
137+ val stagingDir = layout.buildDirectory.dir(" staging-deploy" )
138+
139+ publishing {
140+ publications {
141+ create<MavenPublication >(" maven" ) {
142+ from(components[" java" ])
143+
144+ pom {
145+ name = project.name
146+ description = project.description
147+ url = " https://github.com/komamitsu/jackson-dataformat-msgpack"
148+ licenses {
149+ license {
150+ name = " Apache-2.0"
151+ url = " https://www.apache.org/licenses/LICENSE-2.0.txt"
152+ }
153+ }
154+ developers {
155+ developer {
156+ id = " komamitsu"
157+ name = " Mitsunori Komatsu"
158+ email = " komamitsu@gmail.com"
159+ url = " https://github.com/komamitsu"
160+ }
161+ }
162+ scm {
163+ url = " https://github.com/komamitsu/jackson-dataformat-msgpack"
164+ connection = " scm:git:git://github.com/komamitsu/jackson-dataformat-msgpack.git"
165+ developerConnection = " scm:git:ssh://git@github.com/komamitsu/jackson-dataformat-msgpack.git"
166+ }
143167 }
144168 }
145- developers {
146- developer {
147- id = " komamitsu"
148- name = " Mitsunori Komatsu"
149- email = " komamitsu@gmail.com"
150- url = " https://github.com/komamitsu"
151- }
169+ }
170+ repositories {
171+ maven {
172+ name = " staging"
173+ url = uri(stagingDir)
152174 }
153- scm {
154- url = " https://github.com/komamitsu/jackson-dataformat-msgpack"
155- connection = " scm:git:git://github.com/komamitsu/jackson-dataformat-msgpack.git"
156- developerConnection = " scm:git:ssh://git@github.com/komamitsu/jackson-dataformat-msgpack.git"
175+ }
176+ }
177+
178+ jreleaser {
179+ signing {
180+ pgp {
181+ active = Active .ALWAYS
182+ armored = true
183+ }
184+ }
185+ deploy {
186+ maven {
187+ mavenCentral.create(" sonatype" ) {
188+ active = Active .ALWAYS
189+ url = " https://central.sonatype.com/api/v1/publisher"
190+ applyMavenCentralRules = true
191+ stagingRepository(stagingDir.get().asFile.path)
192+ }
157193 }
158194 }
159195}
0 commit comments