korlibs / korge-hello-world-client-server

Skeleton showing how to create a client-server project Korge/Ktor with shared common code
3 stars 0 forks source link

client / server setup for JS and Desktop targets #1

Open Ereldev opened 2 years ago

Ereldev commented 2 years ago

Hi,

I'm trying to setup a project with the client / server setup with a shared module as this sample.

But I have a problem when I want to target JS & Desktop platforms !

Here is my build.gradle.kts for the client module:

import com.soywiz.korge.gradle.*

apply<KorgeGradlePlugin>()

korge {
    id = "com.ereldev.rotsg"

    targetJs()
    targetDesktop()

    dependencyProject(":shared")
}

dependencies {
    //add("commonMainImplementation", project(":shared"))
}

If I'm targeting the JS platform I have this error:

Could not determine the dependencies of task ':client:compileProductionExecutableKotlinJs'.
> Could not resolve all task dependencies for configuration ':client:jsCompileClasspath'.
   > Could not resolve project :shared.
     Required by:
         project :client
      > No matching variant of project :shared was found. The consumer was configured to find a usage of 'kotlin-api' 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' capability rotsg:shared:unspecified declares an API 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 'jvmRuntimeElements' capability rotsg:shared:unspecified 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 'metadataApiElements' capability rotsg:shared:unspecified declares a usage of 'kotlin-api' of a library, preferably optimized for non-jvm:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' 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 'mingwX64ApiElements' capability rotsg:shared:unspecified declares a usage of 'kotlin-api' of a library, preferably optimized for non-jvm:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' 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 'mingwX64CInteropApiElements' capability rotsg:shared:unspecified declares a library, preferably optimized for non-jvm:
              - Incompatible because this component declares a usage of 'kotlin-cinterop' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed a usage of 'kotlin-api' 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')

For the Desktop platform I have another error during the build:

e: E:\dev\rotsg\shared\build\platforms\native-desktop\bootstrap.kt: (5, 103): No value passed for parameter 'args'

I'm not really expérimented with Korge and Gradle so maybe I'm missing something obvious !

It is possible to make this client / server setup working with other targets than Jvm ?

Regards !

soywiz commented 2 years ago

Have you tried to copy this code and project at it is here and move your .kt files to the right folders?