Is there currently a workaround for having a jvm a...
# multiplatform
l
Is there currently a workaround for having a jvm and android sourceset in the same kmm module right now? I'm getting the error that the java plugin is incompatible with the Android plugin. It looks like separate source sets aren't possible right now (I want to use expect/actual for several platforms).
My current workaround is to use System.getProperty to determine if we're on Android in jvmMain and using my isRunningOnAndroid() in the actual. Is there a better solution?
Here's an example of what I'm doing in jvmMain: val isRunningOnAndroid by lazy { System.getProperty("java.specification.vendor").contains("Android") || System.getProperty("java.vendor.url").contains("Android") || System.getProperty("java.vendor").contains("Android") || System.getProperty("java.vm.vendor").contains("Android") } internal actual val platform: Platform = if(isRunningOnAndroid) Platform.Android else Platform.JVM internal actual val arch: Arch = Arch.Jvm
j
In my jvm subproject I have this:
Copy code
plugins {
    kotlin("jvm")
    id("kotlin-platform-jvm")
    id("war")
    id("application")
    kotlin("plugin.serialization")
    id("kotlinx-serialization")
}
and in my shared build file:
Copy code
plugins {
    kotlin("multiplatform")
    id("kotlinx-serialization")
    id("com.android.library")
    id("org.jetbrains.kotlin.native.cocoapods")
    id("com.codingfeline.buildkonfig")
}
kotlin {
    android()
    iosX64()
    iosArm64()
    iosSimulatorArm64()
    jvm {
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
This builds, my only problem is that my jvm subproject goes to androidMain instead of jvmMain for the actual methods/classes. You can see it at https://github.com/jblack975/MyOutfitPicker/tree/initial_ui
👍 1
l
Interesting. I'll have to look into this.