Trying to test Kotlin 1.9.0-Beta with the matching...
# compose-web
o
Trying to test Kotlin 1.9.0-Beta with the matching Jetpack Compose prerelease compiler. Found that it is still missing a Multiplatform fix for K/Js+Serialization which was committed almost 5 months ago (see comment in https://github.com/JetBrains/compose-multiplatform/issues/3229). While the docs say
The gap between a Compose Multiplatform release and a Jetpack Compose release is usually 1 to 3 months.
I expected the gap to be shorter in the other direction. Any suggestions about how to optimally test Kotlin pre-releases with Compose Multiplatform, including Web? Would using the K/Wasm target instead of K/Js be the easier route?
o
The gap that the docs mentions is about taking the changes from the upstream into our fork. The time gap for the other direction (from the fork to the upstream) is not specified. For minor kotlin version releases it's usually fine to do as described here: https://github.com/JetBrains/compose-multiplatform/blob/master/VERSIONING.md#disabling-kotlin-compatibility-check For 1.8.x to 1.9.x update it can fail unfortunately, but it's worth trying:
Copy code
compose {
    kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.8.20"))
    // or kotlinCompilerPlugin.set("1.4.5")
   // or even kotlinCompilerPlugin.set("1.4.7-rc01")
    kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.9.0-Beta")
}
Such a block has to be added in all modules with compose. It will try to use the Compose Multiplatform Compiler plugin 1.4.5 with kotlin 1.9.0-Beta _ This one is likely to work: In this particular case (newer kotlin version support), k/wasm target is a bit ahead because for k/wasm we wanted to integrate and test the changes from k/wasm more frequently. https://github.com/Kotlin/kotlin-wasm-examples/tree/jetsnacks-kotlin190/compose-jetsnack - this branch contains some workarounds to run the jetsnack demo with 1.9.0-Beta. Kotlinx serialization with wasm suppor is here - https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental/org/jetbrains/kotlinx/kotlinx-serialization-core-wasm/1.5.1-wasm0/ _ But if you aim to test k/js 1.9.0-Beta, testing k/wasm won't guarantee a flawless k/js app (although k/js is stable, it still can have different than k/wasm issues). __ And this all is defenitely not optimal as it requires adding a bunch of extra code lines and experimental maven repos here and there. I guess this is an improvement opportunity for us.
o
Thank you for hinting at the various options. I'm already using
suppressKotlinVersionCompatibilityCheck
and next time I'll hopefully remember that this is preferable to using a newer Jetpack compiler if Js is involved. K/Js is not a priority for me with Wasm on the horizon, just waiting for all those multiplatform libraries to support the new target. This time I just wanted to offer feedback on Kotlin 1.9 as soon as possible to help getting stuff fixed for the RC. And yes, while there's a potential for improvement, I'm more worried about the extra effort on your side getting those Multiplatform changes synced with upstream when diffs are becoming larger. So all good for me, thanks again and just keep moving! 🦜
For the record, I'm running a local build of Kotlin 1.9.0-Beta plus some fixes, and a local build of the Compose Multiplatform Gradle plugin (including the fix for compose-multiplatform#3169). It runs quite nicely with this configuration for Desktop and Web/Js/Canvas targets:
Copy code
compose {
    kotlinCompilerPlugin.set(dependencies.compiler.forKotlin("1.8.20"))
    kotlinCompilerPluginArgs.add("suppressKotlinVersionCompatibilityCheck=1.9.255-SNAPSHOT")
}
(I could not try HTML/Dom yet due to another issue.)
o
jfyi: compiler plugin 1.4.7.1-beta was released with 1.9.0-Beta support
(I could not try HTML/Dom yet due to another issue.)
Is it a compiler plugin issue?
o
The compiler plugin 1.4.7.1-beta works well for me. Excellent! 🎉 And the other issue is a Gradle/Multiplatform dependency consumer issue, which I need to isolate a bit more. I have a multiplatform subproject called
base
which contains a JVM backend, a JVM frontend (Compose Desktop), a Js frontend (Compose Web), and a third JVM target for integration tests (backend + headless Compose frontend). Then there is a subproject called
frontend-js-dom
(Compose HTML) which consumes
:base
. And this produces dependency resolving issues:
Copy code
Could not determine the dependencies of task ':frontend-js-dom:compileProductionExecutableKotlinFrontendJsDom'.
> Could not resolve all task dependencies for configuration ':frontend-js-dom:frontendJsDomRuntimeClasspath'.
   > Could not resolve project :base.
     Required by:
         project :frontend-js-dom
      > The consumer was configured to find a usage of 'kotlin-runtime' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir'. However we cannot choose between the following variants of project :base:
          - frontendJsUiPublicPackageJsonConfiguration
          - frontendJsUiRuntimeElements
          - koverArtifact
        All of them match the consumer attributes:
          - Variant 'frontendJsUiPublicPackageJsonConfiguration' capability com.example:base:0.0-SNAPSHOT declares a usage of 'kotlin-runtime' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir', attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
              - Unmatched attributes:
                  - Provides attribute 'org.jetbrains.kotlin.js.public.package.json' with value 'public-package-json' but the consumer didn't ask for it
                  - Provides attribute 'targetName' with value 'frontendJsUi' but the consumer didn't ask for it
          - Variant 'frontendJsUiRuntimeElements' capability com.example:base:0.0-SNAPSHOT declares a usage of 'kotlin-runtime' of a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir', attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
              - Unmatched attribute:
                  - Provides attribute 'targetName' with value 'frontendJsUi' but the consumer didn't ask for it
          - Variant 'koverArtifact' capability com.example:base:0.0-SNAPSHOT:
              - Unmatched attributes:
                  - Provides attribute 'kotlinx.kover.artifact.name' with value '' but the consumer didn't ask for it
                  - Provides attribute 'kotlinx.kover.kotlin.plugin' with value 'MULTIPLATFORM' but the consumer didn't ask for it
                  - Provides attribute 'kotlinx.kover.project.path' with value ':base' but the consumer didn't ask for it
                  - Doesn't say anything about its component category (required a library)
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about its usage (required a usage of 'kotlin-runtime')
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'js')
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'backendJvmApiElements' capability com.example:base:0.0-SNAPSHOT declares a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'backendJvmRuntimeElements' capability com.example:base:0.0-SNAPSHOT declares a runtime of a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'backendJvmSourcesElements' capability com.example:base:0.0-SNAPSHOT declares a runtime of a component, preferably optimized for standard JVMs:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'frontendJsUiApiElements' capability com.example:base:0.0-SNAPSHOT declares a library, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir', attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
              - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed a usage of 'kotlin-runtime' of a component
          - Variant 'frontendJsUiSourcesElements' capability com.example:base:0.0-SNAPSHOT declares a usage of 'kotlin-runtime' of a component, preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir', attribute 'org.jetbrains.kotlin.platform.type' with value 'js':
              - Incompatible because this component declares documentation and the consumer needed a library
          - Variant 'frontendJvmApiElements' capability com.example:base:0.0-SNAPSHOT declares a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'frontendJvmRuntimeElements' capability com.example:base:0.0-SNAPSHOT declares a runtime of a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'frontendJvmSourcesElements' capability com.example:base:0.0-SNAPSHOT declares a runtime of a component, preferably optimized for standard JVMs:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'integrationJvmApiElements' capability com.example:base:0.0-SNAPSHOT declares a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'integrationJvmRuntimeElements' capability com.example:base:0.0-SNAPSHOT declares a runtime of a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'integrationJvmSourcesElements' capability com.example:base:0.0-SNAPSHOT declares a runtime of a component, preferably optimized for standard JVMs:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'metadataApiElements' capability com.example:base:0.0-SNAPSHOT declares a library, preferably optimized for non-jvm:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a usage of 'kotlin-runtime' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'metadataSourcesElements' capability com.example:base:0.0-SNAPSHOT declares a usage of 'kotlin-runtime' of a component, preferably optimized for non-jvm:
              - Incompatible because this component declares documentation, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a library, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
              - Other compatible attribute:
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
Found the cause of my problems. It was a Gradle misconfiguration of mine, which did only surface with Kotlin 1.9.0-Beta in conjunction with a
kotlinx-kover
Gradle plugin. So it had nothing to do with Compose. In those two Kotlin Multiplatform subprojects where one had a dependency on the other, each of them had a Js target with a unique name. On the consumer subproject, I forgot to disambiguate the target per name. This worked until Kotlin 1.8.21. It also worked with Kotlin 1.9.0-Beta without the kotlinx-kover plugin. But failed when both conditions were met. Correctly disambiguating the target in the consumer subproject made everything work again. I'm now happily using Kotlin 1.9.0-Beta (plus local fixes) with the Compose Gradle plugin 1.5.0-dev1063 and the Compose compiler plugin 1.4.7.1-beta. Works nicely with Desktop, Web/Js/Canvas and HTML frontends. 😃
128 Views