diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000..f748a1246e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,28 @@ +import io.github.gradlenexus.publishplugin.NexusPublishExtension +import java.time.Duration + +plugins { + id("io.github.gradle-nexus.publish-plugin") +} + +// We use gradle-nexus's publish-plugin to publish all of our published artifacts to Maven using OSSRH. +// Documentation for this plugin, see https://github.com/gradle-nexus/publish-plugin/blob/v2.0.0/README.md +// This plugin must be applied at the root project, so we include the following block around the nexus publish +// extension. +rootProject.run { + plugins.apply("io.github.gradle-nexus.publish-plugin") + extensions.getByType(NexusPublishExtension::class.java).run { + this.repositories { + sonatype { + nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/")) + username.set(properties["ossrhUsername"].toString()) + password.set(properties["ossrhPassword"].toString()) + } + } + + // these are not strictly required. The default timeouts are set to 1 minute. But Sonatype can be really slow. + // If you get the error "java.net.SocketTimeoutException: timeout", these lines will help. + connectTimeout.set(Duration.ofMinutes(3)) + clientTimeout.set(Duration.ofMinutes(3)) + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 5e57cc0d94..aabb8501b6 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -27,6 +27,7 @@ object Versions { const val dokka = "1.6.10" const val kotlin = "1.6.20" const val ktlintGradle = "10.2.1" + const val nexusPublish = "2.0.0" const val pig = "0.6.1" const val shadow = "8.1.1" } @@ -36,6 +37,7 @@ object Plugins { const val dokka = "org.jetbrains.dokka:dokka-gradle-plugin:${Versions.dokka}" const val kotlinGradle = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}" const val ktlintGradle = "org.jlleitschuh.gradle:ktlint-gradle:${Versions.ktlintGradle}" + const val nexusPublish = "io.github.gradle-nexus:publish-plugin:${Versions.nexusPublish}" const val pig = "org.partiql:pig-gradle-plugin:${Versions.pig}" const val shadow = "com.github.johnrengelman:shadow:${Versions.shadow}" } @@ -45,6 +47,7 @@ dependencies { implementation(Plugins.dokka) implementation(Plugins.kotlinGradle) implementation(Plugins.ktlintGradle) + implementation(Plugins.nexusPublish) implementation(Plugins.pig) implementation(Plugins.shadow) } diff --git a/buildSrc/src/main/kotlin/org/partiql/gradle/plugin/publish/PublishPlugin.kt b/buildSrc/src/main/kotlin/org/partiql/gradle/plugin/publish/PublishPlugin.kt index f36e3c7772..56364c7c30 100644 --- a/buildSrc/src/main/kotlin/org/partiql/gradle/plugin/publish/PublishPlugin.kt +++ b/buildSrc/src/main/kotlin/org/partiql/gradle/plugin/publish/PublishPlugin.kt @@ -29,7 +29,6 @@ import org.gradle.jvm.tasks.Jar import org.gradle.kotlin.dsl.create import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.getByName -import org.gradle.kotlin.dsl.provideDelegate import org.gradle.plugins.signing.SigningExtension import org.gradle.plugins.signing.SigningPlugin import org.jetbrains.dokka.gradle.DokkaPlugin @@ -122,7 +121,7 @@ abstract class PublishPlugin : Plugin { licenses { license { name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") } } developers { @@ -160,17 +159,6 @@ abstract class PublishPlugin : Plugin { } } } - repositories { - maven { - url = uri("https://aws.oss.sonatype.org/service/local/staging/deploy/maven2") - credentials { - val ossrhUsername: String by rootProject - val ossrhPassword: String by rootProject - username = ossrhUsername - password = ossrhPassword - } - } - } } // Sign only if publishing to Maven Central