I have a Kotlin Multiplatform Gradle Multi-Project with two subprojects:
- yass2-core: base project
- yass2-tail: depends on yass2-core
versions: 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"))
}
}
}
}
}
The main dependency works fine but the test dependency gives the gradle error:
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.
So what is the correct way to define the test dependency?