我有一个带有两个子项目的Kotlin Multiplatform Gradle Multi-Project:
版本:Gradle 6.3,Kotlin 1.3.71,Java 11.0.6
build.gradle.kts:
val coreProject = project("yass2-core") {
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(kotlin("stdlib-common"))
}
}
val commonTest by getting {
dependencies {
}
}
}
}
}
project("yass2-tail") {
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
api(coreProject)
}
}
val commonTest by getting {
dependencies {
implementation(project(":yass2-core", "commonTestImplementation"))
}
}
}
}
}
主要依赖项可以正常工作,但是 test 依赖项会产生gradle错误:
Could not determine the dependencies of task ':yass2-tail:jvmTest'.
> Could not resolve all task dependencies for configuration ':yass2-tail:jvmTestRuntimeClasspath'.
> Could not resolve project :yass2-core.
Required by:
project :yass2-tail
> Selected configuration 'commonTestImplementation' on 'project :yass2-core'
but it can't be used as a project dependency because it isn't intended for consumption by other components.
那么定义 test 依赖关系的正确方法是什么?