Skip to content

Commit cc7b0a5

Browse files
committed
chore: build-logic plugins refactorings
1 parent 705cd56 commit cc7b0a5

File tree

16 files changed

+192
-206
lines changed

16 files changed

+192
-206
lines changed

backend/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Run the backend JVM app
2+
3+
```bash
4+
$ ./gradlew :backend:run
5+
```

build.gradle.kts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import common.commonProjectName
2-
31
plugins {
42
plugins.common
53
plugins.misc
64
kotlin("multiplatform") apply false
75
}
86

97
// Multi module single coverage report
10-
dependencies {
11-
kover(project(":$commonProjectName"))
12-
kover(project("backend"))
13-
kover(project("web"))
14-
}
8+
dependencies { project.subprojects.forEach { kover(project(":${it.name}")) } }

common/build.gradle.kts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ plugins {
55
plugins.kotlin.mpp
66
}
77

8+
description = "Shared common module for all projects"
9+
810
application {
911
mainClass = "dev.suresh.ApplicationKt"
1012
applicationDefaultJvmArgs +=
@@ -16,4 +18,26 @@ application {
1618
)
1719
}
1820

19-
dependencies { jvmMainImplementation(libs.slf4j.api) }
21+
dependencies {
22+
// Common multiplatform dependencies
23+
commonMainImplementation(libs.kotlinx.io.bytestring)
24+
commonMainImplementation(libs.kotlinx.io.core)
25+
commonMainImplementation(libs.ktor.client.core)
26+
commonMainImplementation(libs.ktor.client.logging)
27+
commonMainImplementation(libs.ktor.client.serialization)
28+
commonMainImplementation(libs.ajalt.colormath)
29+
commonMainImplementation(libs.benasher44.uuid)
30+
commonMainImplementation(libs.intellij.markdown)
31+
commonMainImplementation(libs.kotlin.codepoints.deluxe)
32+
commonMainImplementation(libs.multiplatform.settings)
33+
// commonMainImplementation(libs.kotlinx.html)
34+
// commonMainImplementation(libs.store5)
35+
36+
// jvmMainImplementation(libs.slf4j.api)
37+
}
38+
39+
// kotlin.sourceSets.commonMain {
40+
// dependencies {
41+
// implementation(libs.kotlinx.io.core)
42+
// }
43+
// }

common/src/commonMain/kotlin/dev/suresh/Platform.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Greeting {
1616

1717
fun greeting() =
1818
"""
19-
| ${BuildConfig.time} - ${KData("Foo", 123, "xxxx")}: Kotlin $platform!
19+
| ${BuildConfig.time} - ${KData("Foo", 123, "test")}: Kotlin $platform: ${KotlinVersion.CURRENT}!
2020
| ${kotlinxTests()}
2121
"""
2222
.trimMargin()
@@ -33,7 +33,7 @@ class Greeting {
3333

3434
return """
3535
|${Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault())}
36-
|${json.encodeToString(KData("Bar", 123, "xxxx"))}
36+
|${json.encodeToString(KData("Bar", 123, "test"))}
3737
|${bs.decodeToString()}
3838
"""
3939
.trimMargin()

desktop/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ import common.mppTargetName
33
plugins { plugins.kotlin.mpp }
44

55
mppTargetName = "desktop"
6+
7+
dependencies { implementation(projects.common) }

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ kotlin.daemon.jvmargs=--show-version --enable-preview
1818
kotlin.jvm.target.validation.mode=warning
1919
kotlin.build.report.output=build_scan
2020
kotlinx.atomicfu.enableJvmIrTransformation=true
21+
kotlinx.atomicfu.enableJsIrTransformation=true
2122

2223
# MPP
2324
kotlin.mpp.enableCInteropCommonization=true

gradle/build-logic/common-plugins/src/main/kotlin/plugins/graalvm.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ graalvmNative {
103103
// https://www.graalvm.org/dashboard/?ojr=help%3Btopic%3Dgetting-started.md
104104
}
105105

106+
resources {
107+
autodetection {
108+
enabled = true
109+
restrictToProjectDependencies = false
110+
}
111+
}
112+
106113
jvmArgs = listOf("--add-modules=$addModules", "-Xmx4G")
107114
systemProperties = mapOf("java.awt.headless" to "false")
108-
resources { autodetect() }
109115
}
110116
}
111117
metadataRepository { enabled = true }

gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.jvm.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ dependencies {
7070
implementation(libs.kotlinx.coroutines.core)
7171
implementation(libs.kotlinx.serialization.json)
7272
implementation(libs.kotlinx.datetime)
73+
implementation(libs.kotlinx.atomicfu)
7374
// Auto-service
7475
ksp(libs.ksp.auto.service)
7576
implementation(libs.google.auto.annotations)

gradle/build-logic/common-plugins/src/main/kotlin/plugins/kotlin.mpp.gradle.kts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ plugins {
1414
java
1515
kotlin("plugin.serialization")
1616
id("com.google.devtools.ksp")
17+
id("kotlinx-atomicfu")
1718
id("dev.zacsweers.redacted")
1819
id("org.jetbrains.dokka")
1920
id("org.jetbrains.kotlinx.kover")
@@ -117,16 +118,9 @@ kotlinMultiplatform.apply {
117118
dependencies {
118119
implementation(libs.kotlinx.coroutines.core)
119120
implementation(libs.kotlinx.datetime)
121+
implementation(libs.kotlinx.atomicfu)
120122
implementation(libs.kotlinx.serialization.json)
121-
implementation(libs.kotlinx.io.bytestring)
122123
implementation(libs.kotlinx.collections.immutable)
123-
implementation(libs.kotlinx.io.core)
124-
implementation(libs.ktor.client.core)
125-
implementation(libs.ktor.client.logging)
126-
implementation(libs.ktor.client.serialization)
127-
implementation(libs.ajalt.colormath)
128-
implementation(libs.benasher44.uuid)
129-
implementation(libs.intellij.markdown)
130124
}
131125
}
132126

@@ -167,6 +161,12 @@ ksp {
167161
arg("autoserviceKsp.verbose", "true")
168162
}
169163

164+
atomicfu {
165+
transformJvm = true
166+
transformJs = true
167+
jvmVariant = "VH"
168+
}
169+
170170
redacted { enabled = true }
171171

172172
kover {

gradle/build-logic/common-plugins/src/main/kotlin/settings/repos.settings.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ pluginManagement {
1313
resolutionStrategy {
1414
eachPlugin {
1515
when (requested.id.id) {
16-
"kotlinx-atomicfu" ->
17-
useModule("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${requested.version}")
1816
"app.cash.licensee" ->
1917
useModule("app.cash.licensee:licensee-gradle-plugin:${requested.version}")
2018
}

0 commit comments

Comments
 (0)