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

Tianyu Zhu

03/21/2023, 7:56 PM
I have a Kotlin Multiplatform project that uses Kotlin/JS and Kotlin/JVM. Here's a short version of my
build.gradle.kts
Copy code
plugins {
  kotlin("multiplatform")
  application
}

application {
  mainClass.set("path.to.my.MainKt")
}

kotlin {
  js()
  jvm()
}
I'd like to use
gradlew run
to run the
path.to.my.MainKt
file, but the
run
task doesn't want to use the runtime classpath in
jvmMain
. How do I fix this problem?
e

ephemient

03/21/2023, 8:49 PM
you can't use Gradle's
application
with Kotllin multiplatform without
withJava()
if you use
kotlin { jvm { withJava() } }
then the
application
plugin should work, but you can't add Android platform (because it conflicts with Java)
if that is an issue for you, you will have to create your own replacement for the
application
plugin, as I did in https://youtrack.jetbrains.com/issue/KT-50227
t

Tianyu Zhu

03/21/2023, 10:07 PM
@ephemient Thank you!
5 Views