From 6ad25a70d817743049dc003ab86dd6311e497127 Mon Sep 17 00:00:00 2001 From: AJ Date: Tue, 3 Sep 2024 19:37:11 -0700 Subject: [PATCH 1/9] Make omnibus publish on all MPP targets --- mordant-omnibus/build.gradle.kts | 3 +-- .../ajalt/mordant/internal/MppInternal.jvm.kt | 13 +++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mordant-omnibus/build.gradle.kts b/mordant-omnibus/build.gradle.kts index c76bf60bd..ecc3cb86e 100644 --- a/mordant-omnibus/build.gradle.kts +++ b/mordant-omnibus/build.gradle.kts @@ -1,10 +1,9 @@ plugins { - id("mordant-kotlin-conventions") + id("mordant-mpp-conventions") id("mordant-publishing-conventions") } kotlin { - jvm() sourceSets { commonMain.dependencies { api(project(":mordant")) diff --git a/mordant/src/jvmMain/kotlin/com/github/ajalt/mordant/internal/MppInternal.jvm.kt b/mordant/src/jvmMain/kotlin/com/github/ajalt/mordant/internal/MppInternal.jvm.kt index 314873410..452b6ba6c 100644 --- a/mordant/src/jvmMain/kotlin/com/github/ajalt/mordant/internal/MppInternal.jvm.kt +++ b/mordant/src/jvmMain/kotlin/com/github/ajalt/mordant/internal/MppInternal.jvm.kt @@ -157,15 +157,24 @@ internal actual fun readFileIfExists(filename: String): String? { } } +private const val DUMB_RAW_MODE_ERROR = """Cannot find terminal interface that supports raw mode. + +You need at least one of the `:mordant-jvm-*` modules on your classpath. +The `:mordant` module includes all of them as transitive dependencies. +If you're using `:mordant-core` instead, you need to add one or more manually. +If you're using only `:mordant-jvm-ffm`, make sure you're running with JVM 22+, and are passing +`--enable-native-access=ALL-UNNAMED` as a JVM argument. +""" + private object DumbTerminalInterface : StandardTerminalInterface() { override fun stdoutInteractive(): Boolean = true override fun stdinInteractive(): Boolean = true override fun getTerminalSize(): Size? = null override fun enterRawMode(mouseTracking: MouseTracking): AutoCloseable { - throw UnsupportedOperationException("Cannot enter raw mode on this system") + throw UnsupportedOperationException(DUMB_RAW_MODE_ERROR) } override fun readInputEvent(timeout: TimeMark, mouseTracking: MouseTracking): InputEvent? { - throw UnsupportedOperationException("Cannot read input on this system") + throw UnsupportedOperationException(DUMB_RAW_MODE_ERROR) } } From 73ae6df4574c44485812a94d39687c02553dcc1e Mon Sep 17 00:00:00 2001 From: AJ Date: Fri, 6 Sep 2024 16:19:58 -0700 Subject: [PATCH 2/9] Try moving jvm() out of convention file --- buildSrc/src/main/kotlin/mordant-js-conventions.gradle.kts | 2 +- buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts | 4 ---- .../src/main/kotlin/mordant-native-conventions.gradle.kts | 1 - mordant-coroutines/build.gradle.kts | 1 + mordant-omnibus/build.gradle.kts | 1 + mordant/build.gradle.kts | 1 + 6 files changed, 4 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/kotlin/mordant-js-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-js-conventions.gradle.kts index fa442add7..490f3bc2a 100644 --- a/buildSrc/src/main/kotlin/mordant-js-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-js-conventions.gradle.kts @@ -20,7 +20,7 @@ kotlin { sourceSets { val jsCommonMain by creating { dependsOn(commonMain.get()) } jsMain.get().dependsOn(jsCommonMain) - getByName("wasmJsMain").dependsOn(jsCommonMain) + wasmJsMain.get().dependsOn(jsCommonMain) } } diff --git a/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts index b1e206bc7..b3fb3a586 100644 --- a/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts @@ -3,7 +3,3 @@ plugins { id("mordant-js-conventions") id("mordant-native-conventions") } - -kotlin { - jvm() -} diff --git a/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts index 97e280421..14fb087d2 100644 --- a/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts @@ -1,5 +1,4 @@ plugins { - kotlin("multiplatform") id("mordant-native-core-conventions") } diff --git a/mordant-coroutines/build.gradle.kts b/mordant-coroutines/build.gradle.kts index add6b4fa1..1a6231a90 100644 --- a/mordant-coroutines/build.gradle.kts +++ b/mordant-coroutines/build.gradle.kts @@ -4,6 +4,7 @@ plugins { } kotlin { + jvm() sourceSets { commonMain.dependencies { api(project(":mordant")) diff --git a/mordant-omnibus/build.gradle.kts b/mordant-omnibus/build.gradle.kts index ecc3cb86e..d84465f1a 100644 --- a/mordant-omnibus/build.gradle.kts +++ b/mordant-omnibus/build.gradle.kts @@ -4,6 +4,7 @@ plugins { } kotlin { + jvm() sourceSets { commonMain.dependencies { api(project(":mordant")) diff --git a/mordant/build.gradle.kts b/mordant/build.gradle.kts index 5153aa2c3..7f7ae68bb 100644 --- a/mordant/build.gradle.kts +++ b/mordant/build.gradle.kts @@ -4,6 +4,7 @@ plugins { } kotlin { + jvm() sourceSets { all { languageSettings.optIn("kotlinx.cinterop.ExperimentalForeignApi") From 1eeff9bac6b4901c02bf07cfa0284ae7498e2918 Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 09:31:12 -0700 Subject: [PATCH 3/9] Try reordering includes --- buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts | 3 ++- .../src/main/kotlin/mordant-native-core-conventions.gradle.kts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts index b3fb3a586..7ecd69bfe 100644 --- a/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts @@ -1,5 +1,6 @@ plugins { + kotlin("multiplatform") id("mordant-kotlin-conventions") - id("mordant-js-conventions") id("mordant-native-conventions") + id("mordant-js-conventions") } diff --git a/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts index 780a11077..50d2d0226 100644 --- a/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts @@ -3,6 +3,8 @@ plugins { } kotlin { + applyDefaultHierarchyTemplate() + linuxX64() linuxArm64() macosX64() @@ -22,7 +24,6 @@ kotlin { // watchosX64() // watchosSimulatorArm64() - applyDefaultHierarchyTemplate() // https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template sourceSets { From 46bb9114b2ed35d6396265259ffc0557c55fd83d Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 10:34:43 -0700 Subject: [PATCH 4/9] Work around KT-52344K --- .../kotlin/mordant-mpp-conventions.gradle.kts | 1 - .../mordant-native-conventions.gradle.kts | 9 -------- ...mordant-native-core-conventions.gradle.kts | 22 ------------------- .../ajalt/mordant/internal/OmibusInternal.kt | 4 ++++ mordant/build.gradle.kts | 22 +++++++++++++++++++ 5 files changed, 26 insertions(+), 32 deletions(-) create mode 100644 mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt diff --git a/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts index 7ecd69bfe..28a69e3fb 100644 --- a/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-mpp-conventions.gradle.kts @@ -1,5 +1,4 @@ plugins { - kotlin("multiplatform") id("mordant-kotlin-conventions") id("mordant-native-conventions") id("mordant-js-conventions") diff --git a/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts index 14fb087d2..4f49e2e9d 100644 --- a/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-native-conventions.gradle.kts @@ -11,13 +11,4 @@ kotlin { watchosArm64() watchosX64() watchosSimulatorArm64() - - sourceSets { - for (target in listOf( - "tvosX64", "tvosArm64", "tvosSimulatorArm64", - "watchosArm32", "watchosArm64", "watchosX64", "watchosSimulatorArm64", - )) { - sourceSets.getByName(target + "Main").kotlin.srcDirs("src/posixSharedMain/kotlin") - } - } } diff --git a/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts b/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts index 50d2d0226..2ede79131 100644 --- a/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/mordant-native-core-conventions.gradle.kts @@ -23,26 +23,4 @@ kotlin { // watchosDeviceArm64() // watchosX64() // watchosSimulatorArm64() - - - // https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template - sourceSets { - val posixMain by creating { dependsOn(nativeMain.get()) } - linuxMain.get().dependsOn(posixMain) - appleMain.get().dependsOn(posixMain) - val appleNonDesktopMain by creating { dependsOn(appleMain.get()) } - for (target in listOf(iosMain, tvosMain, watchosMain)) { - target.get().dependsOn(appleNonDesktopMain) - } - // Kotlin 2.0 changed the way MPP is compiled, so instead of copying shared sources to each - // target, it compiles intermediate sources separately. That means that code that previously - // compiled is broken due to errors like "declaration is using numbers with different bit - // widths". So we copy the shared sources to each target manually. - for (target in listOf( - "linuxX64", "linuxArm64", - "macosX64", "macosArm64", - )) { - sourceSets.getByName(target + "Main").kotlin.srcDirs("src/posixSharedMain/kotlin") - } - } } diff --git a/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt b/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt new file mode 100644 index 000000000..ff7b0a51c --- /dev/null +++ b/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt @@ -0,0 +1,4 @@ +package com.github.ajalt.mordant.internal + +// This file is a workaround for KT-52344, which files to publish a target with no source files +internal val INTERNAL = true diff --git a/mordant/build.gradle.kts b/mordant/build.gradle.kts index 7f7ae68bb..097d0c35c 100644 --- a/mordant/build.gradle.kts +++ b/mordant/build.gradle.kts @@ -20,5 +20,27 @@ kotlin { jvmTest.dependencies { api(libs.systemrules) } + // Kotlin 2.0 changed the way MPP is compiled, so instead of copying shared sources to each + // target, it compiles intermediate sources separately. That means that code that previously + // compiled is broken due to errors like "declaration is using numbers with different bit + // widths". So we copy the shared sources to each target manually. + sourceSets { + // https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template + val posixMain by creating { dependsOn(nativeMain.get()) } + linuxMain.get().dependsOn(posixMain) + appleMain.get().dependsOn(posixMain) + val appleNonDesktopMain by creating { dependsOn(appleMain.get()) } + for (target in listOf(iosMain, tvosMain, watchosMain)) { + target.get().dependsOn(appleNonDesktopMain) + } + for (target in listOf( + "linuxX64", "linuxArm64", + "macosX64", "macosArm64", + "tvosX64", "tvosArm64", "tvosSimulatorArm64", + "watchosArm32", "watchosArm64", "watchosX64", "watchosSimulatorArm64", + )) { + sourceSets.getByName(target + "Main").kotlin.srcDirs("src/posixSharedMain/kotlin") + } + } } } From e450b84301cf4ae1c28c6a61598dcb2c7d4d6973 Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 10:46:49 -0700 Subject: [PATCH 5/9] Apply conventions directly --- mordant-omnibus/build.gradle.kts | 4 +++- .../com/github/ajalt/mordant/internal/OmibusInternal.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mordant-omnibus/build.gradle.kts b/mordant-omnibus/build.gradle.kts index d84465f1a..a96adbac0 100644 --- a/mordant-omnibus/build.gradle.kts +++ b/mordant-omnibus/build.gradle.kts @@ -1,5 +1,7 @@ plugins { - id("mordant-mpp-conventions") + id("mordant-kotlin-conventions") + id("mordant-native-conventions") + id("mordant-js-conventions") id("mordant-publishing-conventions") } diff --git a/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt b/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt index ff7b0a51c..55576f3c3 100644 --- a/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt +++ b/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt @@ -1,4 +1,4 @@ package com.github.ajalt.mordant.internal // This file is a workaround for KT-52344, which files to publish a target with no source files -internal val INTERNAL = true +private val INTERNAL = true From 00397956d370a6c749bb0d182ab828ec259b8e1b Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 10:52:04 -0700 Subject: [PATCH 6/9] Skip conventions --- mordant-omnibus/build.gradle.kts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mordant-omnibus/build.gradle.kts b/mordant-omnibus/build.gradle.kts index a96adbac0..02771b49f 100644 --- a/mordant-omnibus/build.gradle.kts +++ b/mordant-omnibus/build.gradle.kts @@ -1,12 +1,18 @@ +import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl + +// We don't all of the conventions plugins here since applying the mpp=convention results in +// "IllegalStateException: Configuration already finalized for previous property values" plugins { - id("mordant-kotlin-conventions") + kotlin("multiplatform") id("mordant-native-conventions") - id("mordant-js-conventions") id("mordant-publishing-conventions") } kotlin { jvm() + js() + @OptIn(ExperimentalWasmDsl::class) + wasmJs() sourceSets { commonMain.dependencies { api(project(":mordant")) From 50206ff42bc99fa0baefbaedf76c35cc2a06484d Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 10:52:26 -0700 Subject: [PATCH 7/9] typo --- mordant-omnibus/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mordant-omnibus/build.gradle.kts b/mordant-omnibus/build.gradle.kts index 02771b49f..6687ce4a6 100644 --- a/mordant-omnibus/build.gradle.kts +++ b/mordant-omnibus/build.gradle.kts @@ -1,6 +1,6 @@ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl -// We don't all of the conventions plugins here since applying the mpp=convention results in +// We don't use all the conventions plugins here since applying the mpp=convention results in // "IllegalStateException: Configuration already finalized for previous property values" plugins { kotlin("multiplatform") From b69020bc084a85899034b7bd5b1eff9c82f0f697 Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 10:59:00 -0700 Subject: [PATCH 8/9] API dump --- mordant-omnibus/api/mordant-omnibus.api | 0 mordant-omnibus/build.gradle.kts | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 mordant-omnibus/api/mordant-omnibus.api diff --git a/mordant-omnibus/api/mordant-omnibus.api b/mordant-omnibus/api/mordant-omnibus.api new file mode 100644 index 000000000..e69de29bb diff --git a/mordant-omnibus/build.gradle.kts b/mordant-omnibus/build.gradle.kts index 6687ce4a6..35e79c71e 100644 --- a/mordant-omnibus/build.gradle.kts +++ b/mordant-omnibus/build.gradle.kts @@ -10,9 +10,9 @@ plugins { kotlin { jvm() - js() + js { nodejs() } // we don't have any code, but it's an error not to pick aa JS environment @OptIn(ExperimentalWasmDsl::class) - wasmJs() + wasmJs { nodejs() } sourceSets { commonMain.dependencies { api(project(":mordant")) From f0fc7b39daa5ae6c764526873ce0ea2e1cb590e6 Mon Sep 17 00:00:00 2001 From: AJ Date: Sat, 7 Sep 2024 11:00:19 -0700 Subject: [PATCH 9/9] Empty file --- .../com/github/ajalt/mordant/internal/OmibusInternal.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt b/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt index 55576f3c3..a7b3ba75b 100644 --- a/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt +++ b/mordant-omnibus/src/commonMain/kotlin/com/github/ajalt/mordant/internal/OmibusInternal.kt @@ -1,4 +1,4 @@ package com.github.ajalt.mordant.internal -// This file is a workaround for KT-52344, which files to publish a target with no source files -private val INTERNAL = true +// This intentionally empty file is a workaround for KT-52344, which fails to publish a target with +// no source files