From c2182b766a65619c859c0fc871a8a6334d66f199 Mon Sep 17 00:00:00 2001 From: Kamil Doległo <9080183+kamildoleglo@users.noreply.github.com> Date: Wed, 23 Jun 2021 12:33:19 +0200 Subject: Add maven central publication (#1688) * Add OSSRH repositories * Rewrite Gradle plugin publication * Add publication version assertion * Use Nexus publish plugin for publishing to Sonatype * Remove explicit publishing from s3 tests * Don't document Dokka for local publication * Fix a bug with closing Sonatype repository * Bump internal Dokka version * Move publication version check to the validate task * Fix Gradle plugin publication * Bump Dokka and gradle plugin-publish versions * Do not run Dokka for test tasks * Do not fail all runs in a workflow * Reduce JVM memory limit --- build.gradle.kts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'build.gradle.kts') diff --git a/build.gradle.kts b/build.gradle.kts index dca6b9d9..b7026693 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,11 +1,11 @@ -import org.jetbrains.ValidatePublications -import org.jetbrains.configureDokkaVersion +import org.jetbrains.* import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") apply false id("java") - id("org.jetbrains.dokka") version "1.4.10.2" + id("org.jetbrains.dokka") version "1.4.32" + id("io.github.gradle-nexus.publish-plugin") } val dokka_version: String by project @@ -55,16 +55,13 @@ subprojects { val dokkaOutputDir = "$buildDir/dokka" dokkaHtml { + onlyIf { !isLocalPublication } outputDirectory.set(file(dokkaOutputDir)) } - val deleteDokkaOutputDir by registering(Delete::class) { - delete(dokkaOutputDir) - } - register("javadocJar") { - dependsOn(deleteDokkaOutputDir, dokkaHtml) archiveClassifier.set("javadoc") + dependsOn(dokkaHtml) from(dokkaOutputDir) } } @@ -80,3 +77,18 @@ tasks.whenTaskAdded { println("Publication version: $dokka_version") tasks.register("validatePublications") + +nexusPublishing { + repositories { + sonatype { + username.set(System.getenv("SONATYPE_USER")) + password.set(System.getenv("SONATYPE_PASSWORD")) + } + } +} + +tasks.maybeCreate("dokkaPublish").run { + if (publicationChannels.any { it.isMavenRepository }) { + finalizedBy(tasks.named("closeAndReleaseSonatypeStagingRepository")) + } +} -- cgit