From 2a956dd2e10f33d51574627dc04d1b14f26a251c Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Sun, 12 May 2024 21:21:43 +0400 Subject: [PATCH] Use stable Ktor for non-wasm targets Prefer using stable Ktor, because the alpha causes an error with vanilla JavaScript only in production (though is fine in debug). --- catalog/build.gradle.kts | 21 ++++++++++++++------- design/build.gradle.kts | 8 ++++++-- gradle/libs.versions.toml | 4 ++-- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/catalog/build.gradle.kts b/catalog/build.gradle.kts index 7c0f154..0049e34 100644 --- a/catalog/build.gradle.kts +++ b/catalog/build.gradle.kts @@ -68,6 +68,7 @@ kotlin { implementation(compose.foundation) implementation(compose.material3) implementation(libs.kotlinx.serialization.json) + implementation(libs.ktor.client.core) implementation(libs.ktor.serialization.json) implementation(libs.ktor.client.contentNegotiation) @@ -97,8 +98,7 @@ kotlin { } } - val webMain by creating { - dependsOn(commonMain) + val jsMain by getting { resources.srcDirs("src/commonRes", "../sdui/src/commonRes") dependencies { implementation(projects.design) @@ -107,12 +107,19 @@ kotlin { } } - val jsMain by getting { - dependsOn(webMain) - } - val wasmJsMain by getting { - dependsOn(webMain) + dependsOn(commonMain) + resources.srcDirs("src/commonRes", "../sdui/src/commonRes") + dependencies { + implementation(projects.design) + implementation(compose.ui) + + val wasmKtor = "3.0.0-wasm1" + implementation("io.ktor:ktor-client-core:$wasmKtor") + implementation("io.ktor:ktor-serialization-kotlinx-json:$wasmKtor") + implementation("io.ktor:ktor-client-content-negotiation:$wasmKtor") + implementation("io.ktor:ktor-client-logging:$wasmKtor") + } } } } diff --git a/design/build.gradle.kts b/design/build.gradle.kts index c79be9c..5a465af 100644 --- a/design/build.gradle.kts +++ b/design/build.gradle.kts @@ -30,7 +30,7 @@ kotlin { js(IR) { browser() } @OptIn(ExperimentalWasmDsl::class) - wasmJs() { browser() } + wasmJs { browser() } androidTarget { compilations.all { @@ -73,7 +73,6 @@ kotlin { @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) implementation(compose.components.resources) implementation(libs.coil.network.ktor) - implementation(libs.ktor.client.core) } } @@ -81,11 +80,16 @@ kotlin { dependsOn(webMain) dependencies { implementation(libs.ktor.client.js) + implementation(libs.ktor.client.core) } } val wasmJsMain by getting { dependsOn(webMain) + dependencies { + val wasmKtor = "3.0.0-wasm1" + implementation("io.ktor:ktor-client-core:$wasmKtor") + } } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5379b3d..3c52cf8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,7 +7,7 @@ coroutines = "1.8.1" foundation = "1.6.7" kotlin = "1.9.23" kotlinx-serialization = "1.6.3" -ktor = "3.0.0-wasm1" +ktor = "2.3.8" compose-compiler = "1.5.13" compose-jb = "1.6.1" spotless = "6.14.0" @@ -49,4 +49,4 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } jetbrain-compose = { id = "org.jetbrains.compose", version.ref = "compose-jb" } -spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } \ No newline at end of file +spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }