Skip to content

Commit 369f0ac

Browse files
committed
chore: new kotlin DSL changes
1 parent 35c7141 commit 369f0ac

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@ The next version will be based on the semantic version scope (`major`, `minor`,
5757
* Build and Run
5858

5959
```bash
60+
# Kotlin Multiplatform
61+
$ ./gradlew :shared:runJvm
62+
$ ./gradlew :shared:jvmDistZip
63+
# Run task for target 'jvm' and compilation 'main' (it's confusing)
64+
$ ./gradlew :shared:jvmRun
65+
66+
# Kotlin JVM
6067
$ ./gradlew :backend:jvm:run
6168
$ ./gradlew :backend:jvm:build
6269
$ ./gradlew :backend:jvm:jdeprscan
6370
$ ./gradlew :backend:jvm:printModuleDeps
64-
$ ./gradlew :shared:jvmRun
71+
6572

6673
# Benchmark
6774
$ ./gradlew :benchmark:benchmark

backend/jvm/src/main/kotlin/dev/suresh/plugins/Http.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ import io.ktor.server.routing.*
2424
import io.ktor.server.sessions.*
2525
import io.ktor.server.sse.*
2626
import io.ktor.server.websocket.*
27+
import kotlin.concurrent.atomics.*
2728
import kotlin.time.Duration
2829
import kotlin.time.Duration.Companion.seconds
29-
import kotlinx.atomicfu.atomic
30-
import kotlinx.serialization.*
3130
import org.slf4j.event.Level
3231

3332
const val TRACE_ID = "trace-id"
3433

35-
private val counter = atomic(1L)
34+
private val counter = AtomicLong(1L)
3635

3736
fun Application.configureHTTP() {
3837

@@ -87,7 +86,7 @@ fun Application.configureHTTP() {
8786
header(HttpHeaders.XRequestId)
8887
generate {
8988
when (it.isApi) {
90-
true -> "$TRACE_ID-${counter.getAndIncrement()}"
89+
true -> "$TRACE_ID-${counter.incrementAndFetch()}"
9190
else -> "$TRACE_ID-00000"
9291
}
9392
}

gradle/build-logic/src/main/kotlin/common/Multiplatform.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
100100
// val test by testRuns.existing
101101
testRuns.configureEach { executionTask.configure { configureJavaTest() } }
102102

103+
// binaries {
104+
// executable {
105+
// mainClass = libs.versions.app.mainclass
106+
// applicationDefaultJvmArgs = jvmRunArgs
107+
// applicationDistribution.duplicatesStrategy = DuplicatesStrategy.WARN
108+
// }
109+
// }
110+
103111
// Register a task to execute a class using jvm runtime dependencies.
104112
// compilations.getByName("test") {
105113
// tasks.register<JavaExec>("ktExec") {
@@ -108,7 +116,6 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
108116
// }
109117
// }
110118

111-
// attributes.attribute(mppTargetAttr, platformType.name)
112119
// attributes.attribute(KotlinPlatformType.attribute, KotlinPlatformType.jvm)
113120
}
114121

gradle/build-logic/src/main/kotlin/common/ProjectExtns.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ fun KotlinCommonCompilerOptions.configureKotlinCommon(project: Project) =
418418
"kotlin.ExperimentalMultiplatform",
419419
"kotlin.js.ExperimentalJsExport",
420420
"kotlin.uuid.ExperimentalUuidApi",
421+
"kotlin.concurrent.atomics.ExperimentalAtomicApi"
421422
// "org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi",
422-
)
423+
)
423424
}
424425

425426
fun KspAATask.configureKspConfig() =

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
java = "25"
33
kotlin = "2.1.20-Beta2"
4-
kotlin-ksp = "2.1.20-Beta1-1.0.29"
4+
kotlin-ksp = "2.1.20-Beta2-1.0.29"
55
kotlin-jvmtarget = "21"
66
kotlin-dsl-jvmtarget = "21"
77
kotlin-api-version = "2.1"
@@ -49,7 +49,7 @@ kopy = "0.14.0+2.1.10"
4949
poko = "0.18.2"
5050
mappie = "0.10.0"
5151
akkurate = "0.11.0"
52-
kaml = "0.67.0"
52+
kaml = "0.67.1"
5353
snakeyaml-engine-kmp = "3.1.0"
5454
konsist = "0.17.3"
5555
spring-boot = "3.4.2"

shared/src/commonMain/kotlin/dev/suresh/Greeting.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package dev.suresh
33
import dev.suresh.http.json
44
import dev.suresh.lang.*
55
import dev.suresh.serde.toJsonElement
6+
import kotlin.concurrent.atomics.*
67
import kotlin.time.Duration.Companion.seconds
78
import kotlin.uuid.Uuid
8-
import kotlinx.atomicfu.atomic
99
import kotlinx.atomicfu.locks.*
1010
import kotlinx.serialization.json.Json
1111

@@ -92,14 +92,14 @@ class AtomicSample {
9292

9393
private val lock = reentrantLock()
9494

95-
private val _x = atomic(0)
95+
private val _x = AtomicInt(0)
9696

9797
val x
98-
get() = _x.value
98+
get() = _x.load()
9999

100100
fun doWork(finalValue: Int) {
101101
check(x == 0)
102-
check(_x.getAndSet(3) == 0)
102+
check(_x.exchange(3) == 0)
103103
check(x == 3)
104104
check(_x.compareAndSet(3, finalValue))
105105
}

0 commit comments

Comments
 (0)