Kotlin multiplatform java library with multiplatform module dependency

Hi,

I really, really like the new multiplatform model. Whilst we can use multiplatform modules as dependencies in other multiplatform projects and Android modules, if I have a Java library and want to use the multiplatform module as a dependency, that doesn’t seem to work.
e.g.

lib-java-module/build.gradle

implementation project(":lib-multiplatform-module")

With the above, lib-java-module won’t compile if it has any reference to classes in lib-multiplatform-module. I have also tried:

implementation project(path: ":lib-multiplatform-module", configuration: "jvmDefault")

Using configuration jvmDefault the module will compile, but it will throw a ClassNotFoundException the first time it encounters any class that is in lib-multiplatform-module. Once using the configuration jvmDefault in the dependency, the gradle dependencies task seems to show the right dependencies.

Is there a better way to consume a kotlin multiplatform module as a dependency in a java module?

Thanks/regards,

-Mike

Thanks for the report. I reproduced this bug and filed an issue here: https://youtrack.jetbrains.com/issue/KT-31984 If you’re using the 1.3.31 version of Kotlin you should be unaffected. If you believe that your case/project is somehow different, please file a new issue with a sample project to reproduce.