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

JoakimForslund

07/15/2019, 7:53 AM
Wanted to be able to directly run my jvm target in my Multiplatform setup. Using the following kotlin gradle script i'm trying to launch the
Application.kt
file placed inside my package called `box`:
Copy code
tasks.create("run", JavaExec::class) {
    dependsOn("jvmMainClasses", "jvmJar")
    main = "box.ApplicationKt"
    classpath = files(
        kotlin.targets["jvm"].compilations["main"].output.allOutputs.files,
        configurations["jvmRuntimeClasspath"]
    )
    args = listOf()
}
However, this results in :
Error: Could not find or load main class box.ApplicationKt
Anyone have any pointers to run a jvm target?
Added
Application.kt
to the commonMain, and it seems to find that, but still not the jvmMain
Application.kt
Changed to
kotlin.targets["jvm"].compilations["main"].output.allOutputs
and now it seem to work
oh well xD
g

gildor

07/15/2019, 8:30 AM
Are you sure that you need those custom configs? Maybe standard Gradle Application plugin will work (but not sure, because it’s MPP)
j

JoakimForslund

07/15/2019, 1:18 PM
I'd rather have it defined manually for now, but I see it has been suggested before, So i'll try it if this poc comes out of poc phase 😛
g

gildor

07/15/2019, 4:16 PM
You already use it, JavaExec is part of Application plugin, if you apply it it provides preconfigured task (just specify main class name)