Skip to content

Commit

Permalink
Merge branch 'common-gradle-dependencies-release' into plugins-main
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreckYe committed Jul 28, 2022
2 parents 8941857 + 54eced4 commit 8262ddb
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 21 deletions.
2 changes: 1 addition & 1 deletion architecture-common-gradle-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/KotlinVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const val kotlinVersion = "1.7.10"
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/plugin-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
36 changes: 35 additions & 1 deletion common-gradle-dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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-20220714-kotlin-1.6.10"
version = "0.3.0-20220727"

// 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<SourceFile>
) {
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"
)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
@@ -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.1-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
)

0 comments on commit 8262ddb

Please sign in to comment.