如何在子模块之间共享 kotlin 多平台目标?

问题描述

在永恒之后,我设法建立了一个 kotlin 多平台和多模块项目。由于几乎没有合适的指南或文档,我还有一个无法解决的问题。 我可以在子模块之间共享 kotlin 多平台目标吗?

现在每个子模块都有一个 build.gradle.kts 包含:

kotlin {
    jvm {
        compilations.all {
            kotlinoptions.jvmTarget = "15"
        }
    }

    js(IR) {
        nodejs()
        browser {
            testTask {
                useKarma {
                    useChromeHeadless()
                    webpackConfig.cssSupport.enabled = true
                }
            }
        }
    }
}

显然,我希望所有模块都使用相同的版本编译到相同的平台,最好不要为每个模块都复制此代码段。 更不用说测试依赖项也是相同的。

sourceSets {
        val commonTest by getting {
            dependencies {
                implementation("io.kotest:kotest-framework-api:$kotestVersion")
                implementation("io.kotest:kotest-assertions-core:$kotestVersion")
                implementation("io.kotest:kotest-property:$kotestVersion")
            }
        }

        val jvmTest by getting {
            dependsOn(commonTest)
            dependencies {
                implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
            }
        }

        val jsTest by getting {
            dependsOn(commonTest)
            dependencies {
                implementation("io.kotest:kotest-framework-engine:$kotestVersion")
            }
        }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)