From b60d2c4900b32bf33eec6ef4bf103ea58da4734e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 22 May 2022 12:20:14 +0800 Subject: [PATCH 01/25] Use version 0.1.0 of "kotlin-common" --- 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 969c828..ff9ca88 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -2,4 +2,4 @@ plugins { id("build-dependency-library-conventions") } -version = "0.1.0-20220520-dev" +version = "0.1.0-20220522-dev" 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 e9ebaef..f41b314 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.21" - val kotlinCommon = "0.1.0-SNAPSHOT" // TODO + val kotlinCommon = "0.1.0" val exposed = "0.38.2" val kotlinxCoroutines = "1.6.1" From 1762eb90d43abbf30cd7466e6955402c88c6bb3f Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 22 May 2022 16:17:22 +0800 Subject: [PATCH 02/25] Use Kotlin 1.6.10 and Compose Multiplatform 1.1.1 --- architecture-common-gradle-plugins/build.gradle.kts | 2 +- buildSrc/src/main/kotlin/plugin-conventions.gradle.kts | 4 ++-- .../src/main/kotlin/com/huanshankeji/DefaultVersions.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/architecture-common-gradle-plugins/build.gradle.kts b/architecture-common-gradle-plugins/build.gradle.kts index 275e6a6..9719a96 100644 --- a/architecture-common-gradle-plugins/build.gradle.kts +++ b/architecture-common-gradle-plugins/build.gradle.kts @@ -11,7 +11,7 @@ dependencies { //api(project(":common-gradle-dependencies")) implementation(project(":common-gradle-dependencies")) - implementation("org.jetbrains.compose:compose-gradle-plugin:1.2.0-alpha01-dev686") + implementation("org.jetbrains.compose:compose-gradle-plugin:1.1.1") } gradlePlugin { diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index cb13aad..bb95c1e 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -5,10 +5,10 @@ plugins { dependencies { // Not specifying version can cause build issues when added to a project's buildscript dependencies. - implementation(kotlin("gradle-plugin", "1.6.21")) + implementation(kotlin("gradle-plugin", "1.6.10")) } -version = "0.1.1-SNAPSHOT" +version = "0.1.1-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" 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 f41b314..2ef6676 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt @@ -1,7 +1,7 @@ package com.huanshankeji object DefaultVersions { - val kotlin = "1.6.21" + val kotlin = "1.6.10" val kotlinCommon = "0.1.0" From 1bcf316b3f889a349f908f241a977cd8ba8fe0d2 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 22 May 2022 18:51:57 +0800 Subject: [PATCH 03/25] Use dependency versions compatible with Kotlin 1.6.10 --- .../src/main/kotlin/com/huanshankeji/DefaultVersions.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 2ef6676..0de73df 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt @@ -3,15 +3,15 @@ package com.huanshankeji object DefaultVersions { val kotlin = "1.6.10" - val kotlinCommon = "0.1.0" + val kotlinCommon = "0.1.0-kotlin-1.6.10" val exposed = "0.38.2" val kotlinxCoroutines = "1.6.1" val kotlinxHtml = "0.7.5" - val kotlinxSerialization = "1.3.3" + val kotlinxSerialization = "1.3.2" val ktor = "1.6.8" - val arrow = "1.1.2" + val arrow = "1.0.1" val junitJupiter = "5.8.2" val kotest = "5.2.3" val postgreSql = "42.3.5" From 76cffce944464fd72bf097c9264bafe6f9199abb Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 22 May 2022 18:53:24 +0800 Subject: [PATCH 04/25] v0.1.1-kotlin-1.6.10 release --- 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 bb95c1e..6029c8d 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.1-kotlin-1.6.10-SNAPSHOT" +version = "0.1.1-kotlin-1.6.10" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" From 37635a6c4efe7f724c27471f8924317a7011d9d8 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 22 May 2022 19:00:52 +0800 Subject: [PATCH 05/25] Add "kotlin-1.6.10" to the version of "common-gradle-dependencies" --- common-gradle-dependencies/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index ff9ca88..17274ba 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -2,4 +2,4 @@ plugins { id("build-dependency-library-conventions") } -version = "0.1.0-20220522-dev" +version = "0.1.0-20220522-kotlin-1.6.10-dev" From 084f7631be1671b0003102ab85a1bec8474628c9 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 22 May 2022 19:02:03 +0800 Subject: [PATCH 06/25] common-gradle-dependencies v0.1.0-20220522-kotlin-1.6.10 release --- common-gradle-dependencies/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 17274ba..1f31010 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -2,4 +2,4 @@ plugins { id("build-dependency-library-conventions") } -version = "0.1.0-20220522-kotlin-1.6.10-dev" +version = "0.1.0-20220522-kotlin-1.6.10" From bdd1086648603f7bf25add2b04ce5dbd0bbd1399 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 25 May 2022 12:35:44 +0800 Subject: [PATCH 07/25] 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 08/25] 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 09/25] 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 10/25] 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 11/25] 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 12/25] 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" From feff6e8aa134d0d60df88aa212c4f42ac45a8869 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 28 May 2022 16:27:58 +0800 Subject: [PATCH 13/25] Don't throw if the Sonatype OSSRH credentials are not set in Gradle properties --- buildSrc/src/main/kotlin/plugin-conventions.gradle.kts | 2 +- .../kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index b3038b4..0eee5c0 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.4-kotlin-1.6.10-SNAPSHOT" +version = "0.1.5-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-plugin" 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 index 0f5151c..ef4358f 100644 --- 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 @@ -14,7 +14,7 @@ publishing.repositories.maven { 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 + project.findProperty("ossrhUsername")?.let { username = it as String } + project.findProperty("ossrhPassword")?.let { password = it as String } } } From 2d1a136cd0016f7cc82ed0842d9e1b83a88fd637 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 28 May 2022 16:52:40 +0800 Subject: [PATCH 14/25] Make signing not required in "sonatype-ossrh-publish.gradle.kts" --- .../kotlin/com/huanshankeji/sonatype-ossrh-publish.gradle.kts | 1 + 1 file changed, 1 insertion(+) 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 index ef4358f..bbcde11 100644 --- 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 @@ -6,6 +6,7 @@ plugins { } signing { + isRequired = false sign(publishing.publications) } From 715fdc681fe3fc9f411edceacef02911a4f711f6 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 2 Jun 2022 14:36:07 +0800 Subject: [PATCH 15/25] Update `website` and `vcsUrl` in `pluginBundle` --- buildSrc/src/main/kotlin/plugin-conventions.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index 0eee5c0..29da1ff 100644 --- a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts @@ -11,7 +11,7 @@ dependencies { version = "0.1.5-kotlin-1.6.10-SNAPSHOT" pluginBundle { - website = "https://github.com/huanshankeji/gradle-plugin" - vcsUrl = "https://github.com/huanshankeji/gradle-plugin.git" + website = "https://github.com/huanshankeji/gradle-common" + vcsUrl = "$website.git" tags = listOf("kotlin", "multiplatform") } From 0a1c2112bfb2992a1b9b6216f58a99cb2c23e517 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 11 Jun 2022 21:48:11 +0800 Subject: [PATCH 16/25] Add a `production` property to `GenerateKotlinJsBrowserWebrootForVertxWebPlugin.Extension` and determine whether to filter resources with file extensions with it --- .../GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt | 4 +++- buildSrc/src/main/kotlin/plugin-conventions.gradle.kts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt index cf9499c..796af86 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt @@ -28,7 +28,8 @@ class GenerateKotlinJsBrowserWebrootForVertxWebPlugin : Plugin { tasks.register(copyJsBrowserDistributionToResourcesWebroot) { dependsOn(jsBrowserProductionWebpack) from(jsBrowserProductionWebpack.destinationDirectory) - include("*.html", "*.css", "*.js") + if (extension.production.get()) + include("*.html", "*.css", "*.js") into(browserDistributionResourcesDirectory.resolve("webroot")) } @@ -41,5 +42,6 @@ class GenerateKotlinJsBrowserWebrootForVertxWebPlugin : Plugin { interface Extension { val webFrontendProjectPath: Property + val production: Property } } \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index 29da1ff..a1217ae 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.5-kotlin-1.6.10-SNAPSHOT" +version = "0.1.6-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-common" From 907b0590d65fd0798ef5db1add1ea919453c9d2c Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 11 Jun 2022 22:14:01 +0800 Subject: [PATCH 17/25] Also make the `Copy` task depend on the "jsBrowserDevelopmentWebpack" task when not in production mode in `GenerateKotlinJsBrowserWebrootForVertxWebPlugin` --- ...GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt index 796af86..df918c7 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinJsBrowserWebrootForVertxWebPlugin.kt @@ -19,15 +19,18 @@ class GenerateKotlinJsBrowserWebrootForVertxWebPlugin : Plugin { /*val jsBrowserDistributionTask by lazy { tasks.getByPath(extension.webFrontendProjectPath.get() + ":jsBrowserDistribution") as KotlinWebpack }*/ - val jsBrowserProductionWebpack by lazy { - tasks.getByPath(extension.webFrontendProjectPath.get() + ":jsBrowserProductionWebpack") as KotlinWebpack + val jsBrowserWebpack by lazy { + tasks.getByPath( + extension.webFrontendProjectPath.get() + + if (extension.production.get()) ":jsBrowserProductionWebpack" else ":jsBrowserDevelopmentWebpack" + ) as KotlinWebpack } val copyJsBrowserDistributionToResourcesWebroot = "copyJsBrowserDistributionToResourcesWebroot" val browserDistributionResourcesDirectory = buildDir.resolve("browserDistributionResources") tasks.register(copyJsBrowserDistributionToResourcesWebroot) { - dependsOn(jsBrowserProductionWebpack) - from(jsBrowserProductionWebpack.destinationDirectory) + dependsOn(jsBrowserWebpack) + from(jsBrowserWebpack.destinationDirectory) if (extension.production.get()) include("*.html", "*.css", "*.js") into(browserDistributionResourcesDirectory.resolve("webroot")) From 53e1f2ad19a8f7f54d2242723225148d2a5824b9 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 3 Jul 2022 02:13:44 +0800 Subject: [PATCH 18/25] Refactor "common-gradle-dependencies" making the versions configurable and upgrade its version to "0.2.0-SNAPSHOT" --- .../huanshankeji/VersionsAndDependencies.kt | 4 ++ ...tlin-jvm-common-app-conventions.gradle.kts | 6 +- ...n-multiplatform-app-conventions.gradle.kts | 4 +- common-gradle-dependencies/build.gradle.kts | 2 +- .../com/huanshankeji/CommonDependencies.kt | 66 ++++++++++++------- .../kotlin/com/huanshankeji/CommonVersions.kt | 20 ++++++ .../com/huanshankeji/DefaultVersions.kt | 20 ------ 7 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt create mode 100644 common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt delete mode 100644 common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt new file mode 100644 index 0000000..3e509be --- /dev/null +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/VersionsAndDependencies.kt @@ -0,0 +1,4 @@ +package com.huanshankeji + +internal val commonVersions = CommonVersions() +internal val commonDependencies = CommonDependencies(commonVersions) diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts index 64ce4a3..cd9941c 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.gradle.kts @@ -8,11 +8,11 @@ dependencies { implementation(platform(kotlin("bom"))) testImplementation(kotlin("test")) - testImplementation("org.junit.jupiter:junit-jupiter-api:${DefaultVersions.junitJupiter}") + testImplementation("org.junit.jupiter:junit-jupiter-api:${commonVersions.junitJupiter}") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") - implementation(CommonDependencies.Kotlinx.Coroutines.core()) - testImplementation(CommonDependencies.Kotlinx.Coroutines.test()) + implementation(commonDependencies.kotlinx.coroutines.core()) + testImplementation(commonDependencies.kotlinx.coroutines.test()) } tasks.test { diff --git a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts index c884e1c..f2a5693 100644 --- a/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts +++ b/architecture-common-gradle-plugins/src/main/kotlin/com/huanshankeji/kotlin-multiplatform-app-conventions.gradle.kts @@ -9,14 +9,14 @@ kotlin { val commonMain by getting { dependencies { //implementation(platform(kotlin("bom", kotlinVersion))) - implementation(CommonDependencies.Kotlinx.Coroutines.core()) + implementation(commonDependencies.kotlinx.coroutines.core()) } } val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation(CommonDependencies.Kotlinx.Coroutines.test()) + implementation(commonDependencies.kotlinx.coroutines.test()) } } diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 9e2d71b..16effec 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-20220527-dev-kotlin-1.6.10" +version = "0.2.0-SNAPSHOT-20220527-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 69c7c3b..2fed98d 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt @@ -3,9 +3,9 @@ package com.huanshankeji import org.gradle.api.artifacts.dsl.DependencyHandler // some but not all default dependencies -object CommonDependencies { - object KotlinCommon { - val defaultVersion = DefaultVersions.kotlinCommon +class CommonDependencies(val versions: CommonVersions = CommonVersions()) { + inner class KotlinCommon internal constructor() { + val defaultVersion = versions.kotlinCommon fun module(module: String, version: String = defaultVersion) = "com.huanshankeji:kotlin-common-$module:$version" @@ -16,20 +16,24 @@ object CommonDependencies { fun coroutines(version: String = defaultVersion) = module("coroutines", version) fun exposed(version: String = defaultVersion) = module("exposed", version) - object Ktor { + inner class Ktor internal constructor() { fun module(module: String, version: String = defaultVersion) = - KotlinCommon.module("ktor-$module", version) + this@KotlinCommon.module("ktor-$module", version) fun client(version: String = defaultVersion) = module("client", version) } + val ktor = Ktor() + fun serialization(version: String = defaultVersion) = module("serialization", version) fun vertx(version: String = defaultVersion) = module("vertx", version) } - object Kotlinx { - object Coroutines { - val defaultVersion = DefaultVersions.kotlinxCoroutines + val kotlinCommon = KotlinCommon() + + inner class Kotlinx internal constructor() { + inner class Coroutines internal constructor() { + val defaultVersion = versions.kotlinxCoroutines fun module(module: String, version: String = defaultVersion) = kotlinx("coroutines-$module", version) @@ -37,14 +41,18 @@ object CommonDependencies { fun test(version: String = defaultVersion) = module("test", version) } - object Html { - val defaultVersion = DefaultVersions.kotlinxHtml + val coroutines = Coroutines() + + inner class Html internal constructor() { + val defaultVersion = versions.kotlinxHtml fun module(module: String, version: String = defaultVersion) = "org.jetbrains.kotlinx:kotlinx-html-$module:$version" } - object Serialization { - val defaultVersion = DefaultVersions.kotlinxSerialization + val html = Html() + + inner class Serialization internal constructor() { + val defaultVersion = versions.kotlinxSerialization fun module(module: String, version: String = defaultVersion) = kotlinx("serialization-$module", version) @@ -52,13 +60,17 @@ object CommonDependencies { fun protobuf(version: String = defaultVersion) = module("protobuf", version) fun json(version: String = defaultVersion) = module("json", version) } + + val serialization = Serialization() } + val kotlinx = Kotlinx() + // official libraries from JetBrains - object Exposed { - val defaultVersion = DefaultVersions.exposed + inner class Exposed internal constructor() { + val defaultVersion = versions.exposed fun module(module: String, version: String = defaultVersion) = "org.jetbrains.exposed:exposed-$module:$version" @@ -66,25 +78,31 @@ object CommonDependencies { module("core", version) } - object Ktor { - val defaultVersion = DefaultVersions.ktor + val exposed = Exposed() + + inner class Ktor internal constructor() { + val defaultVersion = versions.ktor fun module(module: String, version: String = defaultVersion) = "io.ktor:ktor-$module:$version" - object Client { + inner class Client internal constructor() { fun module(module: String, version: String = defaultVersion) = - Ktor.module("client-$module", version) + this@Ktor.module("client-$module", version) fun core(version: String = defaultVersion) = module("core", version) } + + val client = Client() } + val ktor = Ktor() + // others - object Vertx { - val defaultVersion = DefaultVersions.vertx + inner class Vertx internal constructor() { + val defaultVersion = versions.vertx private fun stackDepchain(version: String = defaultVersion) = moduleWithVersion("stack-depchain", version) @@ -99,12 +117,16 @@ object CommonDependencies { "${moduleWithoutVersion(module)}:$version" } - object Arrow { - val defaultVersion = DefaultVersions.arrow + val vertx = Vertx() + + inner class Arrow internal constructor() { + val defaultVersion = versions.arrow fun module(module: String, version: String = defaultVersion) = "io.arrow-kt:arrow-$module:$version" fun core(version: String = defaultVersion) = module("core", version) } + + val arrow = Arrow() } \ No newline at end of file diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt new file mode 100644 index 0000000..3ca3a1b --- /dev/null +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt @@ -0,0 +1,20 @@ +package com.huanshankeji + +class CommonVersions( + val kotlin: String = "1.6.10", + + val kotlinCommon: String = "0.1.1-kotlin-1.6.10", + + val exposed: String = "0.38.2", + val kotlinxCoroutines: String = "1.6.1", + val kotlinxHtml: String = "0.7.5", + val kotlinxSerialization: String = "1.3.2", + val ktor: String = "1.6.8", + + val arrow: String = "1.0.1", + val junitJupiter: String = "5.8.2", + val kotest: String = "5.2.3", + val postgreSql: String = "42.3.5", + val slf4j: String = "1.7.36", + val vertx: String = "4.2.7", // TODO: 4.3.0 +) \ No newline at end of file diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt deleted file mode 100644 index ce1d6a3..0000000 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.huanshankeji - -object DefaultVersions { - val kotlin = "1.6.10" - - val kotlinCommon = "0.1.1-kotlin-1.6.10" - - val exposed = "0.38.2" - val kotlinxCoroutines = "1.6.1" - val kotlinxHtml = "0.7.5" - val kotlinxSerialization = "1.3.2" - val ktor = "1.6.8" - - val arrow = "1.0.1" - val junitJupiter = "5.8.2" - val kotest = "5.2.3" - val postgreSql = "42.3.5" - val slf4j = "1.7.36" - val vertx = "4.2.7" // TODO: 4.3.0 -} \ No newline at end of file From 7ebcff4a31d52c43adfc3974a5ea9bb99f5795a6 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 3 Jul 2022 02:20:34 +0800 Subject: [PATCH 19/25] Update the "plugins" project version to "0.1.7-kotlin-1.6.10-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 a1217ae..b6ba518 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.6-kotlin-1.6.10-SNAPSHOT" +version = "0.1.7-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-common" From cd90f475dcca0d7f0d9040977326bde4e9881bf5 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 3 Jul 2022 15:34:10 +0800 Subject: [PATCH 20/25] Change the versioning rule remove the "dev" suffix in SNAPSHOT/development versions --- common-gradle-dependencies/build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 16effec..e0f37d2 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -2,6 +2,6 @@ plugins { id("build-dependency-library-conventions") } -// `SNAPSHOT` means it's under development until that version, -// and `dev` means it has been under development since that version. -version = "0.2.0-SNAPSHOT-20220527-dev-kotlin-1.6.10" +// "x.y.z" indicates the version of the way of organizing the code, +// and the date indicates the version when the dependency versions are updated. +version = "0.2.0-20220527-kotlin-1.6.10-SNAPSHOT" From 73cb8d26bb4eb95374078ece5fdf2bc9165d592f Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sun, 3 Jul 2022 15:38:10 +0800 Subject: [PATCH 21/25] common-gradle-dependencies v0.2.0-20220527-kotlin-1.6.10 release --- common-gradle-dependencies/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index e0f37d2..710cf0e 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -4,4 +4,4 @@ plugins { // "x.y.z" indicates the version of the way of organizing the code, // and the date indicates the version when the dependency versions are updated. -version = "0.2.0-20220527-kotlin-1.6.10-SNAPSHOT" +version = "0.2.0-20220527-kotlin-1.6.10" From 59891f62bb17a3115304ef5d39df8feea74bd872 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 14 Jul 2022 14:11:57 +0800 Subject: [PATCH 22/25] Add "kotlinx-datetime" to "common-gradle-dependencies" --- common-gradle-dependencies/build.gradle.kts | 2 +- .../src/main/kotlin/com/huanshankeji/CommonDependencies.kt | 3 +++ .../src/main/kotlin/com/huanshankeji/CommonVersions.kt | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index e0f37d2..2a3557e 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -4,4 +4,4 @@ plugins { // "x.y.z" indicates the version of the way of organizing the code, // and the date indicates the version when the dependency versions are updated. -version = "0.2.0-20220527-kotlin-1.6.10-SNAPSHOT" +version = "0.2.0-20220714-kotlin-1.6.10-SNAPSHOT" 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 2fed98d..d15a962 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt @@ -62,6 +62,9 @@ class CommonDependencies(val versions: CommonVersions = CommonVersions()) { } val serialization = Serialization() + + fun datetime(version: String = versions.kotlinxDatetime) = + kotlinx("datetime", version) } val kotlinx = Kotlinx() diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt index 3ca3a1b..c6edcd6 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt @@ -9,6 +9,7 @@ class CommonVersions( val kotlinxCoroutines: String = "1.6.1", val kotlinxHtml: String = "0.7.5", val kotlinxSerialization: String = "1.3.2", + val kotlinxDatetime: String = "0.4.0", val ktor: String = "1.6.8", val arrow: String = "1.0.1", From 2f307dabf12e75c0f9e8fe151d69e13f5117fe3e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 21 Jul 2022 18:24:00 +0800 Subject: [PATCH 23/25] Add a `jvm-integration-test` plugin extracted from an internal project --- .../build.gradle.kts | 4 +-- buildSrc/src/main/kotlin/ScriptPlugins.kt | 6 ++-- .../main/kotlin/plugin-conventions.gradle.kts | 2 +- kotlin-common-gradle-plugins/build.gradle.kts | 9 +++-- .../jvm-integration-test.gradle.kts | 35 +++++++++++++++++++ 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-integration-test.gradle.kts diff --git a/architecture-common-gradle-plugins/build.gradle.kts b/architecture-common-gradle-plugins/build.gradle.kts index 9719a96..30d875a 100644 --- a/architecture-common-gradle-plugins/build.gradle.kts +++ b/architecture-common-gradle-plugins/build.gradle.kts @@ -17,8 +17,8 @@ dependencies { gradlePlugin { plugins { val `package` = group as String - fun scriptConventionsPlugin(shortName: String, displayNameAndDescription: String) = - scriptPlugin(`package`, shortName, displayNameAndDescription) + fun scriptConventionsPlugin(shortName: String, displayName: String, description: String = displayName) = + scriptPlugin(`package`, shortName, displayName, description) scriptConventionsPlugin( "kotlin-jvm-common-app-conventions", diff --git a/buildSrc/src/main/kotlin/ScriptPlugins.kt b/buildSrc/src/main/kotlin/ScriptPlugins.kt index ecfda09..1740ab5 100644 --- a/buildSrc/src/main/kotlin/ScriptPlugins.kt +++ b/buildSrc/src/main/kotlin/ScriptPlugins.kt @@ -2,9 +2,9 @@ import org.gradle.api.NamedDomainObjectContainer import org.gradle.plugin.devel.PluginDeclaration fun NamedDomainObjectContainer.scriptPlugin( - `package`: String, shortName: String, displayNameAndDescription: String + `package`: String, shortName: String, displayName: String, description: String = displayName ) = getByName("$`package`.$shortName") { - displayName = displayNameAndDescription - description = displayNameAndDescription + this.displayName = displayName + this.description = description } diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index b6ba518..8c9b82c 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.7-kotlin-1.6.10-SNAPSHOT" +version = "0.1.8-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-common" diff --git a/kotlin-common-gradle-plugins/build.gradle.kts b/kotlin-common-gradle-plugins/build.gradle.kts index ef6fa11..ef65be7 100644 --- a/kotlin-common-gradle-plugins/build.gradle.kts +++ b/kotlin-common-gradle-plugins/build.gradle.kts @@ -10,8 +10,8 @@ dependencies { gradlePlugin { plugins { val `package` = group as String - fun scriptConventionsPlugin(shortName: String, displayNameAndDescription: String) = - scriptPlugin(`package`, shortName, displayNameAndDescription) + fun scriptConventionsPlugin(shortName: String, displayName: String, description: String = displayName) = + scriptPlugin(`package`, shortName, displayName, description) scriptConventionsPlugin( "kotlin-jvm-common-conventions", @@ -47,5 +47,10 @@ gradlePlugin { "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" ) + scriptConventionsPlugin( + "jvm-integration-test", + "JVM integration test", + "Adds a JVM integration test source set." + ) } } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-integration-test.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-integration-test.gradle.kts new file mode 100644 index 0000000..6708d73 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-integration-test.gradle.kts @@ -0,0 +1,35 @@ +package com.huanshankeji + +plugins { + java +} + +// code copied and adapted from https://docs.gradle.org/current/userguide/java_testing.html#sec:configuring_java_integration_tests + +sourceSets { + create("intTest") { + compileClasspath += sourceSets.main.get().output + runtimeClasspath += sourceSets.main.get().output + } +} + +val intTestImplementation by configurations.getting { + extendsFrom(configurations.implementation.get()) + extendsFrom(configurations.testImplementation.get()) +} + +configurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get()) + +val integrationTest = task("integrationTest") { + description = "Runs integration tests." + group = "verification" + + testClassesDirs = sourceSets["intTest"].output.classesDirs + classpath = sourceSets["intTest"].runtimeClasspath + shouldRunAfter("test") + + // copied from "kotlin-jvm-common-app-conventions" + useJUnitPlatform() +} + +tasks.check { dependsOn(integrationTest) } From dccd8642630df053b62079b866f989738b27563e Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 21 Jul 2022 19:03:40 +0800 Subject: [PATCH 24/25] Add a `jvm-test-common-feature-variant` plugin extracted from an internal project --- kotlin-common-gradle-plugins/build.gradle.kts | 6 ++++++ ...jvm-test-common-feature-variant.gradle.kts | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts diff --git a/kotlin-common-gradle-plugins/build.gradle.kts b/kotlin-common-gradle-plugins/build.gradle.kts index ef65be7..b6d265b 100644 --- a/kotlin-common-gradle-plugins/build.gradle.kts +++ b/kotlin-common-gradle-plugins/build.gradle.kts @@ -47,10 +47,16 @@ gradlePlugin { "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" ) + scriptConventionsPlugin( "jvm-integration-test", "JVM integration test", "Adds a JVM integration test source set." ) + scriptConventionsPlugin( + "jvm-test-common-feature-variant", + "JVM test common feature variant", + "Adds a JVM test common feature variant with a source set that depends on `main`." + ) } } diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts new file mode 100644 index 0000000..69261c9 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/jvm-test-common-feature-variant.gradle.kts @@ -0,0 +1,20 @@ +package com.huanshankeji + +plugins { + java +} + +val testCommon = "testCommon" + +sourceSets.register(testCommon) { + val mainSourceSet = sourceSets["main"] + compileClasspath += mainSourceSet.compileClasspath + mainSourceSet.output + //runtimeClasspath += + //runtimeClasspath += mainSourceSet.runtimeClasspath + mainSourceSet.output +} + +java.registerFeature(testCommon) { + usingSourceSet(sourceSets[testCommon]) + withJavadocJar() + withSourcesJar() +} From 096a232c40e2af6e87242c9ab0162aad3add0d59 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 21 Jul 2022 22:17:54 +0800 Subject: [PATCH 25/25] Add a `Project.generateKotlinSources` function extracted from an internal project --- .../com/huanshankeji/GenerateKotlinSources.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt diff --git a/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt new file mode 100644 index 0000000..b1555a1 --- /dev/null +++ b/kotlin-common-gradle-plugins/src/main/kotlin/com/huanshankeji/GenerateKotlinSources.kt @@ -0,0 +1,43 @@ +package com.huanshankeji + +import org.gradle.api.Project +import org.gradle.api.tasks.TaskContainer +import org.gradle.api.tasks.TaskProvider +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.invoke +import org.gradle.kotlin.dsl.named +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +class SourceFile(val filePath: String, val content: String) + +fun Project.generateKotlinSources( + taskName: String = "generateSources", sourceDirectoryName: String = "main", sourceFiles: List +) { + val generatedSourcesDir = buildDir.resolve("gen/$sourceDirectoryName/kotlin") + + val task = tasks.register(taskName) { + generatedSourcesDir.mkdirs() + + for (sourceFile in sourceFiles) { + val generatedVersionsSourceFile = generatedSourcesDir.resolve(sourceFile.filePath) + generatedVersionsSourceFile.writeText(sourceFile.content) + } + } + + tasks.compileKotlin { + dependsOn(task) + } + + kotlin.sourceSets["main"].kotlin.srcDir(generatedSourcesDir) +} + + +// copied and adapted from generated sources +// made private to avoid conflicts with generated code + +private val TaskContainer.compileKotlin: TaskProvider + get() = named("compileKotlin") + +private val Project.kotlin: KotlinJvmProjectExtension + get() = extensions.getByName("kotlin") as KotlinJvmProjectExtension