diff --git a/samples/chat/api/build.gradle.kts b/samples/chat/api/build.gradle.kts index e0df9283..3b53e14a 100644 --- a/samples/chat/api/build.gradle.kts +++ b/samples/chat/api/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,8 +14,6 @@ * limitations under the License. */ -import org.jetbrains.kotlin.konan.target.* - plugins { kotlin("multiplatform") kotlin("plugin.serialization") @@ -30,19 +28,14 @@ kotlin { browser() nodejs() } - when { - HostManager.hostIsLinux -> linuxX64("native") - HostManager.hostIsMingw -> null //no native support for TCP in ktor mingwX64("native") - HostManager.hostIsMac -> macosX64("native") - else -> null - } + linuxX64() + macosX64() + macosArm64() sourceSets { - commonMain { - dependencies { - api("io.rsocket.kotlin:rsocket-core:$rsocketVersion") - api("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinxSerializationVersion") - } + commonMain.dependencies { + api("io.rsocket.kotlin:rsocket-core:$rsocketVersion") + api("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinxSerializationVersion") } } } diff --git a/samples/chat/client/src/browserMain/kotlin/App.kt b/samples/chat/build.gradle.kts similarity index 51% rename from samples/chat/client/src/browserMain/kotlin/App.kt rename to samples/chat/build.gradle.kts index cd54f5fe..74b4d1da 100644 --- a/samples/chat/client/src/browserMain/kotlin/App.kt +++ b/samples/chat/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,20 +14,18 @@ * limitations under the License. */ -package io.rsocket.kotlin.samples.chat.client +import org.jetbrains.kotlin.gradle.targets.js.nodejs.* +import org.jetbrains.kotlin.gradle.targets.js.npm.* -import io.rsocket.kotlin.samples.chat.api.* -import kotlinx.coroutines.* +plugins { + kotlin("multiplatform") apply false +} -suspend fun main() { - coroutineScope { - //only WS is supported on browser JS - // native WS server is incompatible with js WS client - (Servers.WS - Servers.Native.WS).forEach { - val client = ApiClient(it, "Yuri") - launch { - client.use(it, "RSocket is awesome! (from browser)") - } - } +plugins.withType { + // ignore package lock + extensions.configure { + lockFileDirectory.set(layout.buildDirectory.dir("kotlin-js-store")) + packageLockMismatchReport.set(LockFileMismatchReport.NONE) + packageLockAutoReplace.set(true) } } diff --git a/samples/chat/client/build.gradle.kts b/samples/chat/client/build.gradle.kts index 0aef8149..db573a8d 100644 --- a/samples/chat/client/build.gradle.kts +++ b/samples/chat/client/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -import org.jetbrains.kotlin.konan.target.* +import org.jetbrains.kotlin.gradle.plugin.mpp.* plugins { kotlin("multiplatform") @@ -33,56 +33,37 @@ kotlin { jvm { withJava() } - js("browser") { - browser { - binaries.executable() - } - } - js("nodejs") { - nodejs { - binaries.executable() - } + js { + browser() + nodejs() + binaries.executable() } - when { - HostManager.hostIsLinux -> linuxX64("native") - HostManager.hostIsMingw -> null //no native support for TCP in ktor mingwX64("clientNative") - HostManager.hostIsMac -> macosX64("native") - else -> null - }?.binaries { - executable { - entryPoint = "io.rsocket.kotlin.samples.chat.client.main" + linuxX64() + macosX64() + macosArm64() + targets.withType().configureEach { + binaries { + executable { + entryPoint = "io.rsocket.kotlin.samples.chat.client.main" + } } } sourceSets { - commonMain { - dependencies { - implementation(project(":api")) - implementation("io.rsocket.kotlin:rsocket-transport-ktor-websocket-client:$rsocketVersion") - } + commonMain.dependencies { + implementation(project(":api")) + implementation("io.rsocket.kotlin:rsocket-transport-ktor-websocket-client:$rsocketVersion") } - val jvmMain by getting { - dependencies { - implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion") - implementation("io.ktor:ktor-client-cio:$ktorVersion") - } + jvmMain.dependencies { + implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion") + implementation("io.ktor:ktor-client-cio:$ktorVersion") } - findByName("nativeMain")?.apply { - dependencies { - implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion") - implementation("io.ktor:ktor-client-cio:$ktorVersion") - } + nativeMain.dependencies { + implementation("io.rsocket.kotlin:rsocket-transport-ktor-tcp:$rsocketVersion") + implementation("io.ktor:ktor-client-cio:$ktorVersion") } - val browserMain by getting { - dependencies { - implementation("io.ktor:ktor-client-js:$ktorVersion") - } - } - val nodejsMain by getting { - dependencies { - implementation("io.ktor:ktor-client-js:$ktorVersion") - implementation("io.rsocket.kotlin:rsocket-transport-nodejs-tcp:$rsocketVersion") - } + jsMain.dependencies { + implementation("io.ktor:ktor-client-js:$ktorVersion") } } } diff --git a/samples/chat/client/src/nodejsMain/kotlin/App.kt b/samples/chat/client/src/jsMain/kotlin/App.kt similarity index 66% rename from samples/chat/client/src/nodejsMain/kotlin/App.kt rename to samples/chat/client/src/jsMain/kotlin/App.kt index ebe4aa58..8592ff9d 100644 --- a/samples/chat/client/src/nodejsMain/kotlin/App.kt +++ b/samples/chat/client/src/jsMain/kotlin/App.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,12 @@ package io.rsocket.kotlin.samples.chat.client import io.rsocket.kotlin.samples.chat.api.* import kotlinx.coroutines.* -suspend fun main() { - coroutineScope { - // native WS server is incompatible with js WS client - (Servers.ALL - Servers.Native.WS).forEach { - val client = ApiClient(it, "Kolya") - launch { - client.use(it, "RSocket is awesome! (from nodeJS)") - } +suspend fun main(): Unit = coroutineScope { + // only WS is supported on browser JS + Servers.WS.forEach { + val client = ApiClient(it, "Kolya") + launch { + client.use(it, "RSocket is awesome! (from js)") } } } diff --git a/samples/chat/client/src/browserMain/kotlin/clientTransport.kt b/samples/chat/client/src/jsMain/kotlin/clientTransport.kt similarity index 94% rename from samples/chat/client/src/browserMain/kotlin/clientTransport.kt rename to samples/chat/client/src/jsMain/kotlin/clientTransport.kt index e18a78b7..8fe31039 100644 --- a/samples/chat/client/src/browserMain/kotlin/clientTransport.kt +++ b/samples/chat/client/src/jsMain/kotlin/clientTransport.kt @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 the original author or authors. + * Copyright 2015-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/samples/chat/client/src/browserMain/resources/index.html b/samples/chat/client/src/jsMain/resources/index.html similarity index 92% rename from samples/chat/client/src/browserMain/resources/index.html rename to samples/chat/client/src/jsMain/resources/index.html index f9897058..c07fddc8 100644 --- a/samples/chat/client/src/browserMain/resources/index.html +++ b/samples/chat/client/src/jsMain/resources/index.html @@ -1,5 +1,5 @@