Title
t

Tomasz Krakowiak

01/09/2022, 9:08 PM
Anyone knows how to create gradle JavaExec configuration for multiplatform project?
tasks.create<JavaExec>("run") {
    classpath = //?
    mainClass.set("com.example.MainKt")
}
sourceSets
container is at this point empty.
configurations
container does not have
jvmMainRuntime
configuration.
h

Hanno

01/09/2022, 9:16 PM
I didnt manage to get it to work either. Workarounded by adding a second gradle subproject for that, maybe thats a feasible workaround for you too up until someone tells us how its done ^^"
e

ephemient

01/09/2022, 9:24 PM
easiest way to do it, IMO:
val jvmJar by tasks.existing
val jvmRuntimeClasspath by configurations.existing
tasks.register<JavaExec>("run") {
    description = "Runs this project as a JVM application"
    group = ApplicationPlugin.APPLICATION_GROUP
    classpath(jvmJar, jvmRuntimeClasspath)
    mainClass.set("...")
}
:thank-you: 1