Skip to content

Commit a04d844

Browse files
committed
chore: kotlin native yaml support
1 parent 3c3bc11 commit a04d844

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

backend/native/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ kotlin {
5050
nativeMain {
5151
dependencies {
5252
api(libs.ktor.client.cio)
53+
api(libs.kaml)
5354
api(libs.kmp.appdirs)
5455
api(libs.kfswatch)
5556
// api(libs.arrow.suspendapp.ktor)

backend/native/src/nativeMain/kotlin/Main.kt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import com.charleskorn.kaml.Yaml
12
import dev.suresh.Greeting
23
import dev.suresh.flow.timerComposeFlow
34
import dev.suresh.http.MediaApiClient
45
import kotlin.reflect.typeOf
56
import kotlin.time.Duration
67
import kotlinx.coroutines.flow.take
78
import kotlinx.coroutines.runBlocking
9+
import kotlinx.serialization.Serializable
810

911
data class ProcessResult(val code: Int, val rawOutput: String?)
1012

@@ -40,8 +42,26 @@ fun main(args: Array<String>): Unit = runBlocking {
4042
// MultiplatformSystem.readEnvironmentVariable()
4143

4244
val client = MediaApiClient()
43-
val images = client.images()
44-
println("Found ${images.size} images")
45+
try {
46+
val images = client.images()
47+
println("Found ${images.size} images")
48+
} catch (e: Exception) {
49+
e.printStackTrace()
50+
}
51+
52+
@Serializable data class Team(val leader: String, val members: List<String>)
53+
54+
val yaml =
55+
Yaml.default.decodeFromString<Team>(
56+
"""
57+
leader: Amy
58+
members:
59+
- Bob
60+
- Cindy
61+
- Dan
62+
"""
63+
.trimIndent())
64+
println(yaml)
4565
}
4666

4767
inline fun <reified T> prop(prop: T): String {

gradle/build-logic/src/main/kotlin/dev.suresh.plugin.kotlin.docs.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ dokka {
7474
separateInheritedMembers = false
7575
mergeImplicitExpectActualDeclarations = false
7676

77-
// val rootPath = rootProject.rootDir
78-
// customAssets.from(rootPath.resolve("app-logo.svg"))
79-
// customStyleSheets.from(rootPath.resolve("logo-styles.css"))
80-
// templatesDir = rootProject.file("dokka-templates")
77+
// customAssets.from(rootDir.resolve("app-logo.svg"))
78+
// customStyleSheets.from(rootDir.resolve("logo-styles.css"))
79+
// templatesDir = rootDir.resolve("dokka-templates")
8180
}
8281
}
8382

gradle/libs.versions.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ kopy = "0.12.0+2.0.21"
4646
poko = "0.17.2"
4747
mappie = "0.8.0"
4848
akkurate = "0.10.0"
49+
kaml = "0.62.0"
50+
snakeyaml-engine-kmp = "3.0.3"
4951
konsist = "0.16.1"
5052
karakum = "1.0.0-alpha.40-K2"
5153
seskar = "3.43.0"
@@ -91,7 +93,7 @@ logback-tyler = "1.0.0"
9193
log4j = "3.0.0-beta2"
9294
jmh = "1.37"
9395
mrjar = "0.1.1"
94-
ktfmt = "0.52"
96+
ktfmt = "0.53"
9597
google-javaformat = "1.24.0"
9698
palantir-javaformat = "2.50.0"
9799
google-auto-service = "1.1.1"
@@ -432,6 +434,10 @@ expiringmap = { module = "net.jodah:expiringmap"
432434
password4j = { module = "com.password4j:password4j" , version.ref = "password4j"}
433435
otp-java = { module = "com.github.bastiaanjansen:otp-java" , version.ref = "otp"}
434436

437+
# Yaml
438+
kaml = { module = "com.charleskorn.kaml:kaml" , version.ref = "kaml"}
439+
snakeyaml-engine-kmp = { module = "it.krzeminski:snakeyaml-engine-kmp" , version.ref = "snakeyaml-engine-kmp"}
440+
435441
# Database IDs
436442
sqids = { module = "org.sqids:sqids" , version.ref = "sqids"}
437443
tsid = { module = "io.hypersistence:hypersistence-tsid" , version.ref = "tsid"}

0 commit comments

Comments
 (0)