From 31031ca038e8ca94031628838137ed82531efdda Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Sat, 21 May 2022 12:19:37 +0800 Subject: [PATCH 1/4] 0.1.0-20220520 release for "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 969c828..b1a39ce 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-20220520" From 47b71e452381c6ad431225f8df8148d298caabad Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Wed, 20 Jul 2022 17:47:32 +0800 Subject: [PATCH 2/4] Update kotlin-common's version to 0.1.2-kotlin-1.6.10 --- common-gradle-dependencies/build.gradle.kts | 2 +- .../src/main/kotlin/com/huanshankeji/CommonVersions.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 2a3557e..6782ea0 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-20220714-kotlin-1.6.10-SNAPSHOT" +version = "0.2.0-20220720-kotlin-1.6.10-SNAPSHOT" 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 c6edcd6..d19e79b 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt @@ -3,7 +3,7 @@ package com.huanshankeji class CommonVersions( val kotlin: String = "1.6.10", - val kotlinCommon: String = "0.1.1-kotlin-1.6.10", + val kotlinCommon: String = "0.1.2-kotlin-1.6.10", val exposed: String = "0.38.2", val kotlinxCoroutines: String = "1.6.1", From f57f207562de8ce1cd385d6a6c6203ab4d92e869 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Mon, 25 Jul 2022 18:20:28 +0800 Subject: [PATCH 3/4] Update the project version to 0.1.9-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 8c9b82c..ab8859c 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.8-kotlin-1.6.10-SNAPSHOT" +version = "0.1.9-kotlin-1.6.10-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-common" From 700f0c85c6904e011d7a94fcd5b380f20e52f26a Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Thu, 28 Jul 2022 16:51:07 +0800 Subject: [PATCH 4/4] Improve common-gradle-dependencies for Version 0.3.0-20220727 Main changes: 1. Update Kotlin to 1.7.10. 1. Update the project versions to "0.3.0-20220727-SNAPSHOT" and "0.1.9-SNAPSHOT". 1. Update all versions in `CommonVersions` and reorder its properties. 1. Add more to `CommonDependencies`. 1. Add `CommonGradleClasspathDependencies`. --- .../build.gradle.kts | 2 +- ...tlin-jvm-common-app-conventions.gradle.kts | 14 ++-- buildSrc/src/main/kotlin/KotlinVersion.kt | 1 + .../main/kotlin/plugin-conventions.gradle.kts | 4 +- common-gradle-dependencies/build.gradle.kts | 36 +++++++++- .../com/huanshankeji/CommonDependencies.kt | 68 +++++++++++++++++++ .../CommonGradleClasspathDependencies.kt | 33 +++++++++ .../kotlin/com/huanshankeji/CommonVersions.kt | 27 ++++---- 8 files changed, 164 insertions(+), 21 deletions(-) create mode 100644 buildSrc/src/main/kotlin/KotlinVersion.kt create mode 100644 common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonGradleClasspathDependencies.kt diff --git a/architecture-common-gradle-plugins/build.gradle.kts b/architecture-common-gradle-plugins/build.gradle.kts index 30d875a..f9a2da7 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.1.1") + implementation("org.jetbrains.compose:compose-gradle-plugin:1.2.0-alpha01-dev753") // TODO: extract "common-gradle-dependencies" into a standalone project and use the dependency there } gradlePlugin { 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 cd9941c..1d9ab80 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,15 @@ dependencies { implementation(platform(kotlin("bom"))) testImplementation(kotlin("test")) - 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()) + with(commonDependencies.orgJunit.jupiter) { + testImplementation(apiWithVersion()) + testRuntimeOnly(engineWithoutVersion()) + } + + with(commonDependencies.kotlinx.coroutines) { + implementation(core()) + testImplementation(test()) + } } tasks.test { diff --git a/buildSrc/src/main/kotlin/KotlinVersion.kt b/buildSrc/src/main/kotlin/KotlinVersion.kt new file mode 100644 index 0000000..e589e85 --- /dev/null +++ b/buildSrc/src/main/kotlin/KotlinVersion.kt @@ -0,0 +1 @@ +const val kotlinVersion = "1.7.10" diff --git a/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts b/buildSrc/src/main/kotlin/plugin-conventions.gradle.kts index ab8859c..f3ca0e3 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.10")) + implementation(kotlin("gradle-plugin", kotlinVersion)) } -version = "0.1.9-kotlin-1.6.10-SNAPSHOT" +version = "0.1.9-SNAPSHOT" pluginBundle { website = "https://github.com/huanshankeji/gradle-common" diff --git a/common-gradle-dependencies/build.gradle.kts b/common-gradle-dependencies/build.gradle.kts index 6782ea0..6e3a6e3 100644 --- a/common-gradle-dependencies/build.gradle.kts +++ b/common-gradle-dependencies/build.gradle.kts @@ -4,4 +4,38 @@ 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-20220720-kotlin-1.6.10-SNAPSHOT" +version = "0.3.0-20220727-SNAPSHOT" + +// copied from GenerateKotlinSources.kt in "kotlin-common-gradle-plugins" +// Depending on a version of "kotlin-common-gradle-plugins" directly might lead to a dependency hell. +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) +} + +generateKotlinSources( + sourceFiles = listOf( + SourceFile( + "GeneratedKotlinVersion.kt", + "internal const val kotlinVersion = \"$kotlinVersion\"\n" + ) + ) +) 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 d15a962..b7b490f 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt @@ -132,4 +132,72 @@ class CommonDependencies(val versions: CommonVersions = CommonVersions()) { } val arrow = Arrow() + + inner class OrgJunit internal constructor() { + val defaultVersion = versions.orgJunit + + private fun bom(version: String = defaultVersion) = + "org.junit:junit-bom:$version" + + fun DependencyHandler.platformBom(version: String = defaultVersion) = + platform(bom(version)) + + inner class Jupiter internal constructor() { + fun withVersion(version: String = defaultVersion) = + "${withoutVersion()}:$version" + + fun withoutVersion() = + "org.junit.jupiter:junit-jupiter" + + fun moduleWithVersion(module: String, version: String = defaultVersion) = + "${moduleWithoutVersion(module)}:$version" + + fun moduleWithoutVersion(module: String) = + "org.junit.jupiter:junit-jupiter-$module" + + fun apiWithVersion(version: String = defaultVersion) = + moduleWithVersion("api", version) + + fun apiWithoutVersion() = + moduleWithoutVersion("api") + + fun engineWithVersion(version: String = defaultVersion) = + moduleWithVersion("engine", version) + + fun engineWithoutVersion() = + moduleWithoutVersion("engine") + } + + val jupiter = Jupiter() + } + + val orgJunit = OrgJunit() + + inner class Kotest internal constructor() { + val defaultVersion = versions.kotest + fun module(module: String, version: String = defaultVersion) = + "io.kotest:kotest-$module:$version" + + fun property(version: String = defaultVersion) = + module("property", version) + } + + val kotest = Kotest() + + fun postgreSql(version: String = versions.postgreSql) = + "org.postgresql:postgresql:$version" + + inner class Slf4j internal constructor() { + val defaultVersion = versions.slf4j + fun module(module: String, version: String = defaultVersion) = + "org.slf4j:slf4j-$module:$version" + + fun api(version: String = defaultVersion) = + module("api", version) + + fun simple(version: String = defaultVersion) = + module("simple", version) + } + + val slf4j = Slf4j() } \ No newline at end of file diff --git a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonGradleClasspathDependencies.kt b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonGradleClasspathDependencies.kt new file mode 100644 index 0000000..f5c421d --- /dev/null +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonGradleClasspathDependencies.kt @@ -0,0 +1,33 @@ +package com.huanshankeji + +import org.gradle.plugin.use.PluginDependenciesSpec + +class CommonGradleClasspathDependencies(val versions: CommonVersions) { + inner class Kotlin internal constructor() { + val group = "org.jetbrains.kotlin" + + inner class SerializationPlugin internal constructor() { + val moduleName = "plugin.serialization" + val version get() = versions.kotlin + } + + val serializationPlugin = SerializationPlugin() + } + + val kotlin = Kotlin() + + inner class ComposeJb internal constructor() { + val gradlePluginProjectGroupAndArtifact = "org.jetbrains.compose:compose-gradle-plugin" + val gradlePluginId = "org.jetbrains.compose" + val defaultVersion = versions.composeJb + + + fun PluginDependenciesSpec.applyPluginWithoutVersion() = + id(gradlePluginId) + + fun PluginDependenciesSpec.applyPluginWithVersion(version: String = defaultVersion) = + applyPluginWithoutVersion().version(version) + } + + val composeJb = ComposeJb() +} 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 d19e79b..8dca6af 100644 --- a/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt +++ b/common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonVersions.kt @@ -1,21 +1,24 @@ package com.huanshankeji +import kotlinVersion + class CommonVersions( - val kotlin: String = "1.6.10", + val kotlin: String = kotlinVersion, - val kotlinCommon: String = "0.1.2-kotlin-1.6.10", + val kotlinCommon: String = "0.2.0", - 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 kotlinxCoroutines: String = "1.6.4", + val kotlinxHtml: String = "0.8.0", + val kotlinxSerialization: String = "1.4.0-RC", val kotlinxDatetime: String = "0.4.0", - val ktor: String = "1.6.8", + val exposed: String = "0.38.2", + val ktor: String = "2.0.3", + val composeJb: String = "1.2.0-alpha01-dev753", // TODO: try to use a stable version in production - 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 vertx: String = "4.3.2", + val arrow: String = "1.1.2", + val orgJunit: String = "5.9.0", + val kotest: String = "5.4.0", + val postgreSql: String = "42.4.0", val slf4j: String = "1.7.36", - val vertx: String = "4.2.7", // TODO: 4.3.0 ) \ No newline at end of file