https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
t

thalescm

09/23/2020, 3:29 PM
Hi, I have a jvm project which I’m trying to turn into multiplatform, as I want to extend that to other platforms and there is things I’m able to share. The problem is, my main jvm target (named
app
), not multiplatform, is not recognizing the code from the multiplatform module (named
shared
). Gradle sync is fine, so I imagine the problem is not on there. app/build.gradle.kts:
Copy code
plugins {
    kotlin("jvm")
    application
    id("org.openjfx.javafxplugin") version("0.0.8")
    kotlin("plugin.serialization")
}

dependencies {
    <other jvm deps>

    implementation(project(":shared"))
}

group = "group"
version = "1.0-SNAPSHOT"

application {
    mainClass.set("pac.kage.MainKt")
}

javafx {
    version = "12"
    modules = listOf("javafx.controls", "javafx.fxml", "javafx.graphics")
}

tasks.withType<JavaExec>().configureEach {
    doFirst {
        println("Desktop classpath: ${classpath.asPath}")
        jvmArgs = listOf(
                "--module-path", classpath.asPath,
                "--add-modules", "javafx.controls",
                "--add-modules", "javafx.fxml",
                "--add-modules", "javafx.graphics"
        )
    }
}

tasks.withType<Test>().configureEach {
    useJUnitPlatform()
}
And the shared/build.gradle.kts:
Copy code
plugins {
    kotlin("multiplatform")
    id("kotlinx-serialization")
}

kotlin {
    jvm {
        val main by compilations.getting {
            output
        }
    }
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib-common"))
            }
        }
        val jvmMain by getting {
            dependencies {
                implementation(ExternalDeps.jipes)
                implementation(kotlin("stdlib"))
            }
        }
    }
}
s

sergiocarabantes

10/10/2020, 10:15 AM
is there any update on this? I have the same issue 😞
t

thalescm

10/10/2020, 9:45 PM
No 😕 Since it wasn’t a priority right now I didn’t spent more time in it. But apparently what was happening was only IDE related indeed. Compilation was fine, but indexing was all wrong. Android Studio kept thinking the jvm module should be indexed alongside
androidMain
instead of
jvmMain
2 Views