diff --git a/.evergreen/publish.sh b/.evergreen/publish.sh index 9a3e9eb405..ee21c7f215 100755 --- a/.evergreen/publish.sh +++ b/.evergreen/publish.sh @@ -18,12 +18,12 @@ export ORG_GRADLE_PROJECT_signingKey="${SIGNING_KEY}" export ORG_GRADLE_PROJECT_signingPassword=${SIGNING_PASSWORD} if [ "$RELEASE" == "true" ]; then - TASK="publishArchives" + TASK="publishArchives closeAndReleaseSonatypeStagingRepository" else TASK="publishSnapshots" fi -SYSTEM_PROPERTIES="-Dorg.gradle.internal.publish.checksums.insecure=true -Dorg.gradle.internal.http.connectionTimeout=120000 -Dorg.gradle.internal.http.socketTimeout=120000" +SYSTEM_PROPERTIES="-Dorg.gradle.internal.publish.checksums.insecure=true" ./gradlew -version ./gradlew ${SYSTEM_PROPERTIES} --stacktrace --info ${TASK} # Scala 2.13 is published as result of this gradle execution. diff --git a/README.md b/README.md index cc0fe3b913..1fbad5f2d7 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ time. ## Binaries Binaries and dependency information for Maven, Gradle, Ivy and others can be found at -[http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.mongodb%22%20AND%20a%3A%22mongodb-driver-sync%22). +[https://central.sonatype.com/search](https://central.sonatype.com/search?namespace=org.mongodb&name=mongodb-driver-sync). Example for Maven: @@ -100,12 +100,19 @@ Snapshot builds are also published regulary via Sonatype. Example for Maven: ```xml - - - sonatype-snapshot - https://oss.sonatype.org/content/repositories/snapshots/ - - + + + Central Portal Snapshots + central-portal-snapshots + https://central.sonatype.com/repository/maven-snapshots/ + + false + + + true + + + ``` ## Build diff --git a/build.gradle.kts b/build.gradle.kts index 287017f0ed..3112e2c59b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,8 +13,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import java.time.Duration plugins { id("eclipse") id("idea") + alias(libs.plugins.nexus.publish) +} + +val nexusUsername: Provider = providers.gradleProperty("nexusUsername") +val nexusPassword: Provider = providers.gradleProperty("nexusPassword") + +nexusPublishing { + packageGroup.set("org.mongodb") + repositories { + sonatype { + username.set(nexusUsername) + password.set(nexusPassword) + + // central portal URLs + nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/")) + snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/")) + } + } + + connectTimeout.set(Duration.ofMinutes(5)) + clientTimeout.set(Duration.ofMinutes(30)) + + transitionCheckOptions { + // We have many artifacts and Maven Central can take a long time on its compliance checks. + // Set the timeout for waiting for the repository to close to a comfortable 50 minutes. + maxRetries.set(300) + delayBetween.set(Duration.ofSeconds(10)) + } } diff --git a/buildSrc/src/main/kotlin/conventions/publishing.gradle.kts b/buildSrc/src/main/kotlin/conventions/publishing.gradle.kts index 8347959b23..b243ce7df2 100644 --- a/buildSrc/src/main/kotlin/conventions/publishing.gradle.kts +++ b/buildSrc/src/main/kotlin/conventions/publishing.gradle.kts @@ -28,8 +28,6 @@ plugins { val signingKey: Provider = providers.gradleProperty("signingKey") val signingPassword: Provider = providers.gradleProperty("signingPassword") -val nexusUsername: Provider = providers.gradleProperty("nexusUsername") -val nexusPassword: Provider = providers.gradleProperty("nexusPassword") @Suppress("UNCHECKED_CAST") val gitVersion: Provider = project.findProperty("gitVersion") as Provider tasks.withType().configureEach { @@ -45,25 +43,8 @@ tasks.withType().configureEach { val localBuildRepo: Provider = rootProject.layout.buildDirectory.dir("repo") -val sonatypeRepositoryReleaseUrl: Provider = provider { - if (version.toString().endsWith("SNAPSHOT")) { - "https://oss.sonatype.org/content/repositories/snapshots/" - } else { - "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - } -} - publishing { repositories { - maven { - url = uri(sonatypeRepositoryReleaseUrl) - if (nexusUsername.isPresent && nexusPassword.isPresent) { - credentials { - username = nexusUsername.get() - password = nexusPassword.get() - } - } - } // publish to local dir, for artifact tracking and testing // `./gradlew publishMavenPublicationToLocalBuildRepository` @@ -141,7 +122,8 @@ tasks.register("publishSnapshots") { description = "Publishes snapshots to Sonatype" if (version.toString().endsWith("-SNAPSHOT")) { - dependsOn(tasks.withType()) + dependsOn(tasks.named("publishAllPublicationsToLocalBuildRepository")) + dependsOn(tasks.named("publishToSonatype")) } } @@ -168,7 +150,8 @@ tasks.register("publishArchives") { } } if (gitVersionMatch) { - dependsOn(tasks.withType()) + dependsOn(tasks.named("publishAllPublicationsToLocalBuildRepository")) + dependsOn(tasks.named("publishToSonatype")) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index eab637a8b4..7341edcda1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -64,6 +64,7 @@ plugin-dokka = "1.8.10" plugin-download = "5.6.0" plugin-graalvm = "0.9.23" plugin-optional-base = "7.0.0" +plugin-nexus-publish = "2.0.0" plugin-shadow = "8.3.6" plugin-spotbugs = "6.0.15" plugin-spotless = "6.14.0" @@ -207,6 +208,7 @@ download = { id = "de.undercouch.download", version.ref = "plugin-download" } graalvm-buildtools = { id = "org.graalvm.buildtools.native", version.ref = "plugin-graalvm" } kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } +nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "plugin-nexus-publish" } optional = { id = "nebula.optional-base", version.ref = "plugin-optional-base" } shadow = { id = "com.gradleup.shadow", version.ref = "plugin-shadow" } spotbugs = { id = "com.github.spotbugs", version.ref = "plugin-spotbugs" }