When creating a multiplatform project, I have .jav...
# multiplatform
j
When creating a multiplatform project, I have .java files in the jvmMain and jvmTest source sets. However, when building the project these files seem to be ignored and only .kt files get compiled. Is there something special I need to do to get the multiplatform configuration to also compile java files in the jvm* source sets?
r
Standard
jvm
target works only with Kotlin source code, similar to
js
and native targets. There is a deprecated undocumented target called
jvmWithJava
, which might suit you, bur it's future is vague. The other way might be to separate your Kotlin+Java code into two separate modules,
kotlin-multirplatform
+
java-library
, but this, of course, will be plausible only if the code is not awfully tangled.
g
I would recommend you to convert the java files to kotlin ones. I’ve did this before and we can do this on a good way. Maybe you will need to manually check something but I think you’ll need less effort in the long run. Or, you may try to configure a new module not using the multiplatform plugin and then import this in your mpp module like if you’re using an external library.