kotlin - 在另一个 kotlin 多平台库中使用 kotlin 多平台库
问题描述
我在 gradle 中使用 intellij 创建了一个多平台 kotlin 库(L1),它在 JS 和 JVM 中构建。
我想在另一个多平台 kotlin lib L2 中重用这个库我该怎么做?
我在 L2 的公共目标中导入 L1 的“公共”部分有问题,(错误很多Unresolved reference
),基本上 L2 的公共目标找不到 L1 中包含的实现。
我只有这个共同目标的问题,js和jvm工作正常。
L1的gradle,要重用的lib
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"))
}
}
}
}
L2的gradle,重用L1的lib:
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"))
}
}
}
}
解决方案
推荐阅读
- xml - 使用 XSLT 从同一输入 XML 中提取的最新日期更新输入 XML
- javascript - 必须填写两个文本字段之一
- sublimetext - sublime 中的项目和工作区有什么区别?
- javascript - 使用 JavaScript 在提到的文本之后/之前删除每一行中的所有内容
- java - 如何降低此函数的时间复杂度?
- python - 如何计算字符串中子字符串的连续出现次数?
- python - 在数据框列的逗号分隔列表中删除值并计算其他值
- r - 同一数据框中不同组的密度图
- javascript - live-server:术语“live-server”未被识别为 cmdlet、函数、脚本文件或可运行程序的名称
- javascript - 为什么 fetch().json() 错误不会触发 window.onerror?