rjaros / kvision

Object oriented web framework for Kotlin/JS
https://kvision.io
MIT License
1.2k stars 67 forks source link

Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 #474

Closed BrownWei closed 1 year ago

BrownWei commented 1 year ago

When adding io.k vision:hikvision-server-spring-boot to KMP, and then executing the frontedMainClasses task, the following error will be reported:

Could not determine the dependencies of task ':frontendPackageJson'.

Could not resolve all dependencies for configuration ':frontendNpm'. Could not resolve org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4. Required by: project : > io.kvision:kvision-server-spring-boot:6.2.3 > io.kvision:kvision-server-spring-boot-js:6.2.3 > org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4 No matching variant of org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 was found. The consumer was configured to find a library for use during 'kotlin-runtime', 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 org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 declares a library:
  • Incompatible because this component declares a component for use during compile-time, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component for use during 'kotlin-runtime', 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 org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4 declares a library for use during runtime:
  • 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')

And sourceSetsconfig as follows:

sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("reflect"))
                implementation(kotlin("stdlib-common"))
                implementation(kotlin("stdlib-jdk8"))
                api("io.kvision:kvision-server-spring-boot:$kvisionVersion")
                configurations.implementation {
                    exclude("ch.qos.logback","logback-classic")
                }
                //implementation("com.soywiz.korlibs.klogger:klogger:2.2.0")
                implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
            }
            kotlin.srcDir("build/generated-src/common")
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val backendMain by getting {
            dependencies {
                implementation(kotlin("reflect"))
                implementation("org.springframework.boot:spring-boot-starter")
                implementation("org.springframework.boot:spring-boot-starter-jetty")
                implementation("org.springframework.boot:spring-boot-devtools")
                implementation("org.springframework.boot:spring-boot-starter-webflux")
                implementation("org.springframework.boot:spring-boot-starter-log4j2")
                compileOnly("org.projectlombok:lombok:1.18.26")
                implementation("javax.mail:javax.mail-api:1.6.2")
                implementation("org.slf4j:slf4j-api:1.7.36")
                implementation("org.slf4j:jcl-over-slf4j:1.7.36")
                implementation("commons-logging:commons-logging:1.2")
                implementation("org.apache.logging.log4j:log4j-api:2.19.0")
                implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.19.0")
                implementation("org.apache.logging.log4j:log4j-core:2.19.0")

                implementation("org.apache.commons:commons-lang3:3.12.0")
                implementation("com.google.code.gson:gson:2.8.9")
            }
        }

        val backendTest by getting {
            dependencies {
                implementation(kotlin("test"))
                implementation(kotlin("test-junit"))
                implementation("org.springframework.boot:spring-boot-starter-test")
            }
        }
        val frontendMain by getting {
            dependencies {
                implementation(npm("react-awesome-button", "6.5.1"))
                implementation(npm("prop-types", "*")) // required by react-awesome-button

                // InspireTree
                implementation(npm("inspire-tree", "6.0.1"))
                implementation(npm("inspire-tree-dom", "4.0.6"))

                //CSS
                implementation(npm("bootstrap", "5.3.0-alpha3"))

                // React, React DOM + Wrappers
                implementation(enforcedPlatform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:$kotlinWrappersVersion"))
                implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
                implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")

                // Kotlin React Emotion (CSS)
                implementation("org.jetbrains.kotlin-wrappers:kotlin-emotion")

                implementation(npm("electron-builder", "^23.6.0"))
                //implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion")
                implementation("io.kvision:kvision:$kvisionVersion")
                implementation("io.kvision:kvision-bootstrap:$kvisionVersion")
                implementation("io.kvision:kvision-bootstrap-upload:$kvisionVersion")
                implementation("io.kvision:kvision-datetime:$kvisionVersion")
                implementation("io.kvision:kvision-tom-select:$kvisionVersion")
                implementation("io.kvision:kvision-fontawesome:$kvisionVersion")
                implementation("io.kvision:kvision-i18n:$kvisionVersion")
                implementation("io.kvision:kvision-richtext:$kvisionVersion")
                implementation("io.kvision:kvision-handlebars:$kvisionVersion")
                implementation("io.kvision:kvision-chart:$kvisionVersion")
                implementation("io.kvision:kvision-tabulator:$kvisionVersion")
                implementation("io.kvision:kvision-pace:$kvisionVersion")
                implementation("io.kvision:kvision-toastify:$kvisionVersion")
                implementation("io.kvision:kvision-react:$kvisionVersion")
                implementation("io.kvision:kvision-routing-navigo:$kvisionVersion")
                implementation("io.kvision:kvision-state:$kvisionVersion")
                implementation("io.kvision:kvision-rest:$kvisionVersion")
                implementation("io.kvision:kvision-imask:$kvisionVersion")
                implementation("io.kvision:kvision-electron:$kvisionVersion")
            }
            kotlin.srcDir("build/generated-src/frontend")
        }
        val frontendTest by getting {
            dependencies {
                implementation(kotlin("test-js"))
                implementation("io.kvision:kvision-testutils:$kvisionVersion")
            }
        }
    }
}
rjaros commented 1 year ago

Unfortunately I can't reproduce your problem. I have created a project with the same dependencies and it compiles fine for me. Could you perhaps share your full project or at least try to create a smaller reproducible example?

BrownWei commented 1 year ago

I think I found out what the problem was. When I added the configure as follows: repositories { mavenLocal() mavenCentral() } then above error occurs. But with the following configure in works fine repositories { mavenCentral() mavenLocal() } so i'm going to find out what the root reason Thanks a lot

BrownWei commented 1 year ago

resolved