Brendan Campbell-hartzell
01/11/2023, 6:44 AMdependsOn
function, which makes it visible at compile time, but when I run the tests, using kotest, I'm getting a NPE the first time I reference a type from the commonMain code. Any way to link these together, or will I have to admit defeat and just make a separate gradle project just for the second test tree?
SOLVED (check thread)Brendan Campbell-hartzell
01/11/2023, 6:45 AMkotlin {
val commonMain by sourceSets.getting
val commonFeatures by sourceSets.creating {
kotlin.srcDir("commonFeatures/kotlin")
resources.srcDir("commonFeatures/resources")
// dependsOn(commonMain) // makes common code visible to compiler, but not at runtime
dependencies {
implementation(commonMain.kotlin)
implementation("io.kotest:kotest-framework-engine:$kotestVersion")
implementation("io.kotest:kotest-assertions-core:$kotestVersion")
}
requiresVisibilityOf(commonMain)
}
jvm {
compilations {
val main by getting
val features by compilations.creating {
defaultSourceSet {
dependsOn(commonFeatures)
dependencies {
implementation(main.compileDependencyFiles + main.output.classesDirs)
implementation("io.kotest:kotest-framework-engine:$kotestVersion")
implementation("io.kotest:kotest-runner-junit5-jvm:$kotestVersion")
}
}
tasks.register<Test>("jvmFeaturesTest") {
group = "verification"
useJUnitPlatform()
classpath = compileDependencyFiles + runtimeDependencyFiles + output.allOutputs
testClassesDirs = output.classesDirs
}
}
}
}
}
Brendan Campbell-hartzell
01/11/2023, 7:12 AM