Skip to content
This repository was archived by the owner on Nov 30, 2025. It is now read-only.
This repository was archived by the owner on Nov 30, 2025. It is now read-only.

Non-JVM targets are not supported #232

@brizzbuzz

Description

@brizzbuzz

Describe the bug

Hey, TBH I'm not sure if this is a bug or just not implemented yet, I'm very new to Kotlin Multiplatform :) I'm trying to leverage Kaml to deserialize some YAML files in a MPP project, but it seems like trying to leverage Kaml in commonMain is not implemented yet when targeting non-JVM applications.

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':satisfaketion-generators:jsTestPackageJson'.
> Could not resolve all dependencies for configuration ':satisfaketion-generators:jsTestNpm'.
   > Could not resolve com.charleskorn.kaml:kaml:0.40.0.
     Required by:
         project :satisfaketion-generators
      > No matching variant of com.charleskorn.kaml:kaml:0.40.0 was found. 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' but:
          - Variant 'jvmApiElements-published' capability com.charleskorn.kaml:kaml:0.40.0 declares a library:
              - 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 attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'jvmRuntimeElements-published' capability com.charleskorn.kaml:kaml:0.40.0 declares a runtime of a library:
              - 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 attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
          - Variant 'metadataApiElements' capability com.charleskorn.kaml:kaml:0.40.0 declares a library:
              - Incompatible because this component declares a usage of 'kotlin-api' 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 attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
                  - Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')

Reproduction repo

So, this is the repo I am currently trying to convert to multiplatform https://github.com/unredundant/satisfaketion. More specifically, the generators module. I can't actually push the code b/c I have some (clearly too lofty) git hooks that prevent me from pushing a broken gradle build and I'm too lazy to delete them 😅 If it would really help I can temporarily remove them and push the code. But effectively, I have a gradle build file like this

plugins {
  kotlin("multiplatform")
  // ...
}

// ...

kotlin {
  sourceSets {
    val commonMain by getting {
      dependencies {
        implementation(kotlin("stdlib"))
        api(projects.satisfaketionCore)  // project dependency (also multiplatform)
        implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
        implementation("com.charleskorn.kaml:kaml:0.40.0")
      }
    }
    val commonTest by getting
    val jvmMain by getting 
    val jvmTest by getting
    val jsMain by getting
    val jsTest by getting
    val nativeMain by getting
    val nativeTest by getting
  }
}

which leads to the error posted above.

Steps to reproduce

  1. Import kaml dependency into MPP project which targets at least JS (presumably native has same issue?)
  2. Try to build
  3. Weep Profit?

Expected behaviour

I'm not sure this is expected behavior, but it would be nice if this was supported :)

Actual behaviour

Stacktrace sadness :(

Version information

Kaml 0.40.0
Kotlin 1.6.10

Any other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions