Inter MPP test source / compilation dependency

Hello

I try to migrate my project to MPP. Now i run into the situation where i need a project dependency to another MPP’s jvm test sourceset / compilation. I tried with a custom configuration / artifact like

configurations {
    testArtifacts
}

task testJar(type: Jar) {
    classifier "test"
    from kotlin.targets.jvm.compilations.test.output.allOutputs
}

artifacts {
    testArtifacts testJar
}

// And in the dependent project
implementation project(':application:base').testArtifacts

And directly

implementation project(':application:base').kotlin.targets.jvm.compilations.test.output.allOutputs

None works reliably. Is there a way for such a dependency?

Update:
It looks like an issue with the project configuration order. I have a further MPP (and a couple more in the future) which depends on “:application:base”'s test as well. And on this project it works as expected.

1 Like

Hello

Finally, my solution is to use evaluationDependsOn for MMP projects they have test dependencies to other MMP’s. The difficult thing here is that this configurations / source sets / outputs are added by the MPP plugin. So all dependency projects have to be evaluated to reference some resources of them.

Maybe this help others they run into a similar situation.