Skip to content

Commit bc22ddf

Browse files
authored
update Gradle build configuration and CI script for Sonatype publishing (#394)
1 parent ae36d2c commit bc22ddf

2 files changed

Lines changed: 19 additions & 21 deletions

File tree

build.gradle

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
plugins {
2-
id 'java-library'
3-
id 'idea'
4-
id 'maven-publish'
5-
id 'signing'
6-
id 'com.github.sherter.google-java-format' version '0.9'
7-
id 'com.google.osdetector' version '1.6.0'
2+
id 'java-library'
3+
id 'idea'
4+
id 'maven-publish'
5+
id 'signing'
6+
id 'com.github.sherter.google-java-format' version '0.9'
7+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
8+
id 'com.google.osdetector' version '1.6.0'
89
}
910

1011
group 'io.tiledb'
1112
version '0.31.0-SNAPSHOT'
1213

1314
repositories {
1415
mavenCentral()
15-
maven {
16-
url "https://ossrh-staging-api.central.sonatype.com/content/repositories/snapshots"
17-
}
1816
}
1917

2018
java {
@@ -238,16 +236,15 @@ publishing {
238236
}
239237
}
240238
}
239+
}
241240

241+
nexusPublishing {
242242
repositories {
243-
maven {
244-
def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
245-
def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
246-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
247-
credentials {
248-
username System.getenv('SONATYPE_CENTRAL_USERNAME')
249-
password System.getenv('SONATYPE_CENTRAL_PASSWORD')
250-
}
243+
sonatype {
244+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
245+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
246+
username.set(System.getenv("SONATYPE_CENTRAL_USERNAME"))
247+
password.set(System.getenv("SONATYPE_CENTRAL_PASSWORD"))
251248
}
252249
}
253250
}

ci/upload_to_maven.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ echo "Starting upload to maven"
55
echo "${GPG_SECRET_KEYS_ENC}" | base64 --decode > $GPG_KEY_LOCATION
66
./gradlew properties -q | grep "version:" | awk '{print $2}'
77
export PROJECT_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')
8-
# Upload only snapshots to sonatype oss so it can make its way to maven central
9-
./gradlew publishMavenJavaPublicationToMavenRepository
108

11-
# Only non-snapshot can be pushed as maven releases
9+
# Publish to Sonatype (Central Portal via OSSRH Staging API).
10+
# IMPORTANT: close/release must run in the SAME Gradle invocation so the plugin can reuse the created staging repository id.
1211
if [[ ! $(echo "${PROJECT_VERSION}" | grep "SNAPSHOT") ]]; then
13-
./gradlew closeAndReleaseRepository
12+
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
13+
else
14+
./gradlew publishToSonatype
1415
fi

0 commit comments

Comments
 (0)