https://kotlinlang.org logo
Title
a

Aaron Todd

06/15/2020, 1:36 PM
Trying to setup integration tests that depend on a common test utility project. Having trouble resolving with Kotlin MPP. Right now just trying to get JVM to work. The "test-utils" project builds fine, gradle seems happy overall but the classes from the "test-utils" project are not resolved and can't be imported in "project A" tests.
// project A

val integrationTest by creating {
    kotlin.srcDir("it")
    dependsOn(getByName("jvmTest"))
    dependencies {
        implementation(project(":test-utils", "jvmMainImplementation"))
        implementation("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
        implementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
    }
}
I've tried various incantations of depending on the "test-utils" project including custom configurations. I was working on setting up a test Jar output but also having trouble with Gradle Kotlin DSL and MPP.
// project "test-utils"
kotlin {
    sourceSets {
        jvmMain {
            dependencies {
                api("org.jetbrains.kotlin:kotlin-test:$kotlinVersion")
                api("org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion")
                ...
            }
        }
    }
}
I can't tell which I'm fighting, Gradle Kotlin DSL, Kotlin MPP, or both. The generic problem: How to setup a custom (test) source set and depend on another project that provides common test utils using Kotlin MPP? I've seen examples of this without Kotlin MPP but that seems to be adding an extra layer that I haven't connected. Any ideas or examples to look at?
👍 1
j

janvladimirmostert

07/02/2020, 10:09 PM
i've started a bounty for something similar, don't know if you've solved your issue yet? https://stackoverflow.com/questions/62665410/linking-dependencies-with-gradle-6-5-in-a-kotlin-multiplatform-project/62667422#62667422
a

Aaron Todd

07/07/2020, 3:11 PM
Sorry have not spent anymore time on this yet
j

janvladimirmostert

07/07/2020, 3:13 PM
issue is solved in that SO question, so if you're looking for sample code, just check out the linked Github Repo
a

Aaron Todd

07/07/2020, 3:13 PM
Awesome thanks! I'll check it out