Skip to content

Multiplatform support for kotlinx-rpc-krpc-ktor-server module #298

@smyrgeorge

Description

@smyrgeorge

Is your feature request related to a problem? Please describe.
I was trying to build my project, that uses the kotlinx-rpc-krpc-ktor-server, for macosArm64 target.
I'm getting the following error:

Could not determine the dependencies of task ':actor4k-cluster:linkDebugExecutableMacosArm64'.
> Could not resolve all dependencies for configuration ':actor4k-cluster:macosArm64CompileKlibraries'.
   > Could not resolve org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.5.1.
     Required by:
         project :actor4k-cluster
      > No matching variant of org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server:0.5.1 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.klib.packaging' with value 'non-packed', attribute 'org.jetbrains.kotlin.native.target' with value 'macos_arm64', attribute 'org.jetbrains.kotlin.platform.type' with value 'native' but:
          - Variant 'jvmApiElements-published' declares a library for use during compile-time, 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 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'jvmRuntimeElements-published' declares a library for use during runtime, 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 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'jvmSourcesElements-published' declares a component for use during runtime, 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 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'metadataApiElements' declares a library, preferably optimized for non-jvm:
              - Incompatible because this component declares a component for use during 'kotlin-metadata', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'metadataSourcesElements' declares a component, preferably optimized for non-jvm:
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'wasmJsApiElements-published' declares a library for use during 'kotlin-api', preferably optimized for non-jvm:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'wasmJsRuntimeElements-published' declares a library, preferably optimized for non-jvm:
              - Incompatible because this component declares a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' and the consumer needed a component for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')
          - Variant 'wasmJsSourcesElements-published' declares a component, preferably optimized for non-jvm:
              - Incompatible because this component declares documentation for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm' and the consumer needed a library for use during 'kotlin-api', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.klib.packaging (required 'non-packed')
                  - Doesn't say anything about org.jetbrains.kotlin.native.target (required 'macos_arm64')

I saw in the source code of krpc that this module only has jvmManin sourceset: https://github.com/Kotlin/kotlinx-rpc/tree/main/krpc/krpc-ktor/krpc-ktor-server.
The krpc-ktor-client has commonMain though.

Describe the solution you'd like
I would like to be able to use this module for non-jvm targets (like native target for example).

Describe alternatives you've considered
I tried to change the jvmMain to commonMain (also I made the change to the build.gradle.kts file) and rebuild the krpc project, but it failed. It seems that other libraries have the same issue (only support jvm).

* What went wrong:
Could not determine the dependencies of task ':kotlinNpmInstall'.
> Could not resolve all dependencies for configuration ':krpc:krpc-ktor:krpc-ktor-server:wasmJsNpmAggregated'.
   > Could not find io.ktor:ktor-server-core-wasm-js:3.0.3.
     Searched in the following locations:
       - https://packages.jetbrains.team/maven/p/krpc/build-deps/io/ktor/ktor-server-core-wasm-js/3.0.3/ktor-server-core-wasm-js-3.0.3.pom
       - https://packages.jetbrains.team/maven/p/krpc/build-deps-eap/io/ktor/ktor-server-core-wasm-js/3.0.3/ktor-server-core-wasm-js-3.0.3.pom
       - file:/Users/smyrgeorge/dev/projects/test/kotlinx-rpc/lib-kotlin/io/ktor/ktor-server-core-wasm-js/3.0.3/ktor-server-core-wasm-js-3.0.3.pom
     Required by:
         project :krpc:krpc-ktor:krpc-ktor-server > io.ktor:ktor-server-core:3.0.3
   > Could not find io.ktor:ktor-server-websockets-wasm-js:3.0.3.
     Searched in the following locations:
       - https://packages.jetbrains.team/maven/p/krpc/build-deps/io/ktor/ktor-server-websockets-wasm-js/3.0.3/ktor-server-websockets-wasm-js-3.0.3.pom
       - https://packages.jetbrains.team/maven/p/krpc/build-deps-eap/io/ktor/ktor-server-websockets-wasm-js/3.0.3/ktor-server-websockets-wasm-js-3.0.3.pom
       - file:/Users/smyrgeorge/dev/projects/test/kotlinx-rpc/lib-kotlin/io/ktor/ktor-server-websockets-wasm-js/3.0.3/ktor-server-websockets-wasm-js-3.0.3.pom
     Required by:
         project :krpc:krpc-ktor:krpc-ktor-server > io.ktor:ktor-server-websockets:3.0.3

From the error, I understand that there is no support for ktor-server-websockets in wasmJs, which it totally understandable. What we can do in this case?

Additional context
If needed, I can provide more context.
Also, If you have in mind a desired solution for this, let me know and I can provide a PR.

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions