2

永遠の後、私は kotlin マルチプラットフォームおよびマルチモジュール プロジェクトをセットアップすることができました。適切なガイドやドキュメントがほとんどないため、解決できなかった問題がもう 1 つあります。サブモジュール間で 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")
            }
        }
}
4

0 に答える 0