To cut to the chase, the issue I’m running into is that I can’t access the Java SDK in my common module because the Kotlin multiplatform gradle plugin assumes that “multiplatform” means “multiple languages/runtimes”, while in my case “multiplatform” means “multiple glue implementations”. I’d love to hear that I’m wrong about this, but if not I’ll probably open an issue.
I’m currently working on setting up a Minecraft mod library that I’d like it to run on two “platforms” (the Minecraft Forge and the Fabric mod loaders) using largely common code and a couple glue modules. This seemed like a perfect place to use a Kotlin multiplatform project, however I ran into the issue above.
The Kotlin IDEA plugin seems to somehow hard-code the lack of a platform SDK, so even if I set the common module’s SDK to a Java one I still can’t access anything from Java. I spent several hours last night trying to get it to work, even going so far as to try and modify the .iml files, but to no avail.
Stripping the problem down to its bare minimum, I want this to compile in the common module:
import com.teamwizardry.librarianlib.core.platform.Platform
import java.io.File
object Common {
fun printImpl() {
val file = File(Platform.platformName)
println(file.absolutePath)
}
}
Here’s the full project: multiplatform_test.zip (85.7 KB)