Skip to content

Commit 534111d

Browse files
sarahchen6bric3
andauthored
Migrate publishing to Maven Central Portal (#8807)
* Update gradle-nexus/publish-plugin version * Update URLs * Run deploy_to_sonatype on this branch commit for now for testing * Change comment url * Update to central portal credentials * Apply suggestion for publishing and consuming snapshots from @bric3 Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com> * Apply documentation suggestion from @bric3 Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com> * Clean comments * Remove testing of deploy_to_sonatype on this branch --------- Co-authored-by: Brice Dutheil <brice.dutheil@gmail.com>
1 parent 640fc88 commit 534111d

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ deploy_to_sonatype:
746746
- when: manual
747747
allow_failure: true
748748
script:
749-
- export SONATYPE_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_username --with-decryption --query "Parameter.Value" --out text)
750-
- export SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.sonatype_password --with-decryption --query "Parameter.Value" --out text)
749+
- export SONATYPE_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_username --with-decryption --query "Parameter.Value" --out text)
750+
- export SONATYPE_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_password --with-decryption --query "Parameter.Value" --out text)
751751
- export GPG_PRIVATE_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_private_key --with-decryption --query "Parameter.Value" --out text)
752752
- export GPG_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.signing.gpg_passphrase --with-decryption --query "Parameter.Value" --out text)
753753
- ./gradlew -PbuildInfo.build.number=$CI_JOB_ID publishToSonatype closeSonatypeStagingRepository -PskipTests $GRADLE_ARGS

build.gradle

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ plugins {
2121
id 'de.thetaphi.forbiddenapis' version '3.8'
2222

2323
id 'pl.allegro.tech.build.axion-release' version '1.14.4'
24-
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
24+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
2525

2626
id 'com.gradleup.shadow' version '8.3.6' apply false
2727
id 'me.champeau.jmh' version '0.7.0' apply false
@@ -92,7 +92,7 @@ nexusPublishing {
9292
def forceLocal = project.hasProperty('forceLocal') && forceLocal
9393
if (forceLocal && !isCI) {
9494
local {
95-
// For testing use with https://hub.docker.com/r/sonatype/nexus
95+
// For testing, use with https://hub.docker.com/r/sonatype/nexus
9696
// docker run --rm -d -p 8081:8081 --name nexus sonatype/nexus:oss
9797
// ./gradlew publishToLocal
9898
// Doesn't work for testing releases though... (due to staging)
@@ -103,7 +103,13 @@ nexusPublishing {
103103
allowInsecureProtocol = true
104104
}
105105
} else {
106+
// see https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-central
107+
// For official documentation:
108+
// staging repo publishing https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
109+
// snapshot publishing https://central.sonatype.org/publish/publish-portal-snapshots/#publishing-via-other-methods
106110
sonatype {
111+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
112+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
107113
username = System.getenv("SONATYPE_USERNAME")
108114
password = System.getenv("SONATYPE_PASSWORD")
109115
}

gradle/repositories.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ repositories {
1818
mavenContent {
1919
snapshotsOnly()
2020
}
21-
url 'https://oss.sonatype.org/content/repositories/snapshots/'
21+
// see https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-via-gradle
22+
url 'https://central.sonatype.com/repository/maven-snapshots/'
2223
}
2324
ivy {
2425
artifactPattern 'https://sqreen-ci-java.s3.amazonaws.com/jars/[organisation]/[artifact]-[revision](-[classifier]).[ext]'

0 commit comments

Comments
 (0)