问题
I have create a multiplatform kotlin librarie (L1)using intellij in gradle, who build in JS and JVM.
I want to reuse this lib in another multiplatform kotlin lib L2 How can I do it?
I have issue with importing the "common" part of L1 in the common target of L2, (the eror are a lot of Unresolved reference
), basicaly the common target of L2 cannot find the implementation contained in L1.
I have only this issue with the common target, the js and jvm work fine.
the gradle of L1, the lib to be reused
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
testRuns["test"].executionTask.configure {
useJUnit()
}
}
js(LEGACY) {
browser {
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
the gradle of L2,the lib who reuse L1:
sourceSets {
val commonMain by getting {
dependencies {
implementation("groupId:L1:1.0-SNAPSHOT")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
implementation("groupId:L1-jvm:1.0-SNAPSHOT")
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting {
dependencies {
implementation("groupId:L1-js:1.0-SNAPSHOT")
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}
来源:https://stackoverflow.com/questions/65233929/use-a-kotlin-multiplatform-lib-in-another-kotlin-multiplatfor-lib