From bdd1086648603f7bf25add2b04ce5dbd0bbd1399 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 25 May 2022 12:35:44 +0800 Subject: [PATCH 1/6] Remove `mavenCentral()` from publishing repositories in "default-maven-publish.gradle.kts" as it cannot be directly published to A common approach is to publish via Sonatype OSSRH. --- .../com/huanshankeji/default-maven-publish.gradle.kts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts index a07a221..31a7ffb 100644 --- a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/default-maven-publish.gradle.kts @@ -5,9 +5,3 @@ plugins { } group = "com.huanshankeji" - -publishing { - repositories { - mavenCentral() - } -} From f2e133b1446ffe5d88b62c7c4a4329a394e8ba59 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 25 May 2022 13:57:26 +0800 Subject: [PATCH 2/6] Update the plugin project version to "0.1.2-SNAPSHOT" --- buildSrc/src/main/kotlin/plugin-conventions.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index cb13aad..b4a04d8 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -8,7 +8,7 @@ dependencies { implementation(kotlin("gradle-plugin", "1.6.21")) } -version = "0.1.1-SNAPSHOT" +version = "0.1.2-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" From 846bc2b067d7acd76953964b8d5141cd297872c4 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 25 May 2022 21:47:24 +0800 Subject: [PATCH 3/6] Add the javadoc jar in a Kotlin Multiplatform project's publications to Maven due to requirements of Maven Central --- ...d-js-browser-default-maven-publish-conventions.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts index e26cd75..5e26175 100644 --- a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts @@ -5,10 +5,15 @@ plugins { id("com.huanshankeji.default-maven-publish") } +val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") +} + publishing { publications { withType { artifactId = "$defaultPrefixForPublishing-$artifactId" + artifact(javadocJar) } } } From 046b93fd0b0a8efa625a848cbb1f278c1dbfcbbf Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 26 May 2022 16:50:53 +0800 Subject: [PATCH 4/6] Move Sonatyp OSSRH publish code here from "kotlin-common" and adapt into script plugins --- .../main/kotlin/plugin-conventions.gradle.kts | 2 +- kotlin-common-gradle-plugins/build.gradle.kts | 9 +++++++++ ...atype-ossrh-publish-conventions.gradle.kts | 6 ++++++ ...fault-maven-publish-conventions.gradle.kts | 13 ++---------- ...atype-ossrh-publish-conventions.gradle.kts | 14 +++++++++++++ .../com/huanshankeji/nexus-staging.gradle.kts | 14 +++++++++++++ .../sonatype-ossrh-publish.gradle.kts | 20 +++++++++++++++++++ 7 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index bed5f2a..90d671f 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -8,7 +8,7 @@ dependencies { implementation(kotlin("gradle-plugin", "1.6.10")) } -version = "0.1.2-kotlin-1.6.10-SNAPSHOT" +version = "0.1.3-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" diff --git a/kotlin-common-gradle-plugins/build.gradle.kts b/kotlin-common-gradle-plugins/build.gradle.kts index 20c8d87..ef6fa11 100644 --- a/kotlin-common-gradle-plugins/build.gradle.kts +++ b/kotlin-common-gradle-plugins/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { //api(project(":common-gradle-dependencies")) + //implementation("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0") } gradlePlugin { @@ -38,5 +39,13 @@ gradlePlugin { "kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions", "Kotlin Multiplatform conventions with the JVM target and the JS browser target, and with default Maven publish" ) + scriptConventionsPlugin( + "kotlin-jvm-library-sonatype-ossrh-publish-conventions", + "Kotlin/JVM library conventions with Sonatype OSSRH Maven Central publish" + ) + scriptConventionsPlugin( + "kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions", + "Kotlin Multiplatform conventions with the JVM target and the JS browser target, and with Sonatype OSSRH Maven Central publish" + ) } } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts new file mode 100644 index 0000000..0c52912 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-library-sonatype-ossrh-publish-conventions.gradle.kts @@ -0,0 +1,6 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.kotlin-jvm-library-default-maven-publish-conventions") + id("com.huanshankeji.sonatype-ossrh-publish") +} diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts index 5e26175..7c8a756 100644 --- a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions.gradle.kts @@ -5,15 +5,6 @@ plugins { id("com.huanshankeji.default-maven-publish") } -val javadocJar by tasks.registering(Jar::class) { - archiveClassifier.set("javadoc") -} - -publishing { - publications { - withType { - artifactId = "$defaultPrefixForPublishing-$artifactId" - artifact(javadocJar) - } - } +publishing.publications.withType { + artifactId = "$defaultPrefixForPublishing-$artifactId" } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts new file mode 100644 index 0000000..2de2905 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-jvm-and-js-browser-sonatype-ossrh-publish-conventions.gradle.kts @@ -0,0 +1,14 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.kotlin-multiplatform-jvm-and-js-browser-default-maven-publish-conventions") + id("com.huanshankeji.sonatype-ossrh-publish") +} + +val javadocJar by tasks.registering(Jar::class) { + archiveClassifier.set("javadoc") +} + +publishing.publications.withType { + artifact(javadocJar) +} diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts new file mode 100644 index 0000000..ac81c71 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/nexus-staging.gradle.kts @@ -0,0 +1,14 @@ +package com.huanshankeji + +/* TODO: this script is not working yet. +plugins { + id("io.codearte.nexus-staging") +} + +group = "com.huanshankeji" + +nexusStaging { + serverUrl = "https://s01.oss.sonatype.org/service/local/" + // TODO +} +*/ diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts new file mode 100644 index 0000000..0f5151c --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts @@ -0,0 +1,20 @@ +package com.huanshankeji + +plugins { + id("com.huanshankeji.default-maven-publish") + signing +} + +signing { + sign(publishing.publications) +} + +publishing.repositories.maven { + val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl) + credentials { + username = project.property("ossrhUsername") as String + password = project.property("ossrhPassword") as String + } +} From ecedde8828cc4c4bdab07a0d0cf750341cdec637 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 27 May 2022 15:28:26 +0800 Subject: [PATCH 5/6] Include sources in the Gradle plugin (Maven) publications and improve `CommonDependencies.Vertx` --- ...uild-dependency-library-conventions.gradle.kts | 3 +++ .../src/main/kotlin/plugin-conventions.gradle.kts | 2 +- common-gradle-dependencies/build.gradle.kts | 4 +++- .../kotlin/com/huanshankeji/CommonDependencies.kt | 15 ++++++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts index 35c05cb..78c8b31 100644 --- a/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/build-dependency-library-conventions.gradle.kts @@ -13,4 +13,7 @@ group = "com.huanshankeji" java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + + withSourcesJar() + withJavadocJar() } diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index 90d671f..b3038b4 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -8,7 +8,7 @@ dependencies { implementation(kotlin("gradle-plugin", "1.6.10")) } -version = "0.1.3-kotlin-1.6.10-SNAPSHOT" +version = "0.1.4-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 17274ba..5dceeb0 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -2,4 +2,6 @@ plugins { id("build-dependency-library-conventions") } -version = "0.1.0-20220522-kotlin-1.6.10-dev" +// `SNAPSHOT` means it's under development until that version, +// and `dev` means it has been under development since that version. +version = "0.1.1-SNAPSHOT-20220522-dev-kotlin-1.6.10" diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt index 914e372..69c7c3b 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt @@ -1,5 +1,7 @@ package com.huanshankeji +import org.gradle.api.artifacts.dsl.DependencyHandler + // some but not all default dependencies object CommonDependencies { object KotlinCommon { @@ -83,11 +85,18 @@ object CommonDependencies { object Vertx { val defaultVersion = DefaultVersions.vertx - fun stackDepchain(version: String = defaultVersion) = - "io.vertx:vertx-stack-depchain:$version" - fun module(module: String) = + private fun stackDepchain(version: String = defaultVersion) = + moduleWithVersion("stack-depchain", version) + + fun DependencyHandler.platformStackDepchain(version: String = defaultVersion) = + platform(stackDepchain(version)) + + fun moduleWithoutVersion(module: String) = "io.vertx:vertx-$module" + + fun moduleWithVersion(module: String, version: String = defaultVersion) = + "${moduleWithoutVersion(module)}:$version" } object Arrow { From 9935c9ccbdd69ff3f9ff5af38ae425a9a3dae6de Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 27 May 2022 21:47:26 +0800 Subject: [PATCH 6/6] Update "kotlin-common" version before it's released --- common-gradle-dependencies/build.gradle.kts | 2 +- .../src/main/kotlin/com/huanshankeji/DefaultVersions.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 5dceeb0..9e2d71b 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -4,4 +4,4 @@ plugins { // `SNAPSHOT` means it's under development until that version, // and `dev` means it has been under development since that version. -version = "0.1.1-SNAPSHOT-20220522-dev-kotlin-1.6.10" +version = "0.1.1-SNAPSHOT-20220527-dev-kotlin-1.6.10" diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt index 0de73df..ce1d6a3 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt @@ -3,7 +3,7 @@ package com.huanshankeji object DefaultVersions { val kotlin = "1.6.10" - val kotlinCommon = "0.1.0-kotlin-1.6.10" + val kotlinCommon = "0.1.1-kotlin-1.6.10" val exposed = "0.38.2" val kotlinxCoroutines = "1.6.1"