refactoring
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
||||
import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.Sync
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
@@ -11,12 +14,33 @@ plugins {
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
js(IR) {
|
||||
// Disable browser-based tests (Karma/Chrome) to avoid ChromeHeadless issues
|
||||
browser {
|
||||
testTask {
|
||||
// Prevent launching ChromeHeadless (snap permission issues on some systems)
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
// Run JS tests in Node.js instead (no browser needed)
|
||||
nodejs {
|
||||
testTask {
|
||||
useMocha()
|
||||
}
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalWasmDsl::class)
|
||||
wasmJs {
|
||||
// Disable browser-based tests for WASM as well to avoid Karma/Chrome
|
||||
browser {
|
||||
commonWebpackConfig {
|
||||
outputFileName = "composeApp.js"
|
||||
}
|
||||
testTask {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
@@ -50,6 +74,37 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Fix duplicate Skiko runtime files being copied from jsMain and jsTest
|
||||
// during JS test packaging by excluding them from jsTest resources and
|
||||
// making Sync tasks ignore duplicates.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
// Exclude Skiko runtime files from jsTest processed resources
|
||||
// to prevent overwriting logs during test packaging.
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val configureJsTestResources = run {
|
||||
// Configure only if the task exists (JS target present)
|
||||
tasks.matching { it.name == "jsTestProcessResources" && it is Copy }.configureEach {
|
||||
(this as Copy).exclude("skiko.*", "skikod8.mjs")
|
||||
}
|
||||
}
|
||||
|
||||
// Also apply the same exclusion for WASM JS test resources, if present
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val configureWasmJsTestResources = run {
|
||||
tasks.matching { it.name == "wasmJsTestProcessResources" && it is Copy }.configureEach {
|
||||
(this as Copy).exclude("skiko.*", "skikod8.mjs")
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure Kotlin/JS generated Sync tasks do not overwrite duplicates noisily
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val configureJsCompileSync = run {
|
||||
tasks.matching { it.name.endsWith("CompileSync") && it is Sync }.configureEach {
|
||||
(this as Sync).duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
}
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package at.mocode
|
||||
|
||||
class JSPlatform: Platform {
|
||||
override val name: String = "JavaScript"
|
||||
}
|
||||
|
||||
actual fun getPlatform(): Platform = JSPlatform()
|
||||
Reference in New Issue
Block a user