I am adding a kotlin multiplatform module to our J...
# multiplatform
a
I am adding a kotlin multiplatform module to our Java-Spring monolith. It compiles just fine, I can use code from the commonMain source root. However: IntelliJ Idea doesn't like this stuff at all. I've attached the build file for the shared module. I've added the module in the main module with
implementation project(":shared")
and I've also added the 2 libraries.
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-datetime:${project.kotlinxDatetime}")
implementation("com.ionspin.kotlin:bignum:${project.bignum}")
I've also tried to export the kotlin-mpp libraries by using the "api"-configuration instead of "implementation" in the shared module. The monolith is Java only. The error message in the IDE is:
Incompatible types. Found: 'kotlinx.datetime.LocalDate', required: 'kotlinx.datetime.LocalDate'
When I add the kotlin plugin and add the same code (converted to kotlin of course) to a kotlin file, it works out just fine.
I only get the error in a java file, and only in the IDE. The IDE is set to use gradle for building the project and the test is green.
c
If you want downstream modules to access the dependencies, they should be declared with
api
. If this exception happened in real code, I would point to classloader magic, maybe you have a framework that does weird things with it? However, if it only happens in the IDE, there's a chance reindexing everything will solve it
a
I've switched back to
api
and reindexing, even removing
.idea
didn't help. 😞 The error is just in IntelliJ Idea, not when I run the test.
c
If you can share the project or create a reproducer, create an issue
a
I guess I'll have to build a minimal example and hope that I can reproduce the issue.
I've made the example: https://github.com/audax/kotlin-mpp-java-type-error I have also isolated the error: As soon as I add any JS target, the IDE shows an error in JavaStuff.java.