Hi, I have a multiplatfrom application project set...
# multiplatform
a
Hi, I have a multiplatfrom application project setup with
jvm()
as one of the targets. When I run
gradlew tasks
I don’t see any way to execute the jvm project. I see the other run tasks for native and js, is there something I need to do to setup the jvm one to be executable?
b
Add application plugin and you'll get run task
a
that adds a run task but doesn’t seem to be setup correctly. Doesn’t appear to build the jvm code or know where the compiled class files are
is there extra setup that needs to be done for the application plugin?
b
You also need to set your main class
a
I set the main class. That’s where it fails saying that class isn’t generated
b
How do you set it?
You also need withJava() in jvm block to make this work with the plugin
a
Oh, that’s what I’m missing
b
No idea why, but it refuses to work without it
a
what’s tgis?
b
Typo
a
I was looking through the source and saw that function I assumed it automatically ran that when using
jvm()
guess not
b
That dsl enables src/jvmMain/java
made a separate module just to run the jvm code though 😞 Would like to have it all in one.
b
Do it manually as I've linked above
Or get it working with application plugin. Both work fine with multiplatform plugin
a
Copy code
jvm {
  withJava()
}
is all I should need to add?
b
No, you also need to add application plugin and set main class properly
a
yeah I did that
b
How do you set main class?
a
Copy code
application {
  mainClass.set("raytracer.console.MainKt")
}
application doesn’t trigger a build there are no compiled class files in the build folder
So I get
Copy code
Error: Could not find or load main class raytracer.console.MainKt
Caused by: java.lang.ClassNotFoundException: raytracer.console.MainKt
b
It should, it triggered everything fone the last time I've used it
a
🤷 last time I tried adding the application plugin broke everything
b
Where does your main file lie? Send me relative path from gradle file
a
src/commonMain/kotlin/raytracer/console/main.kt
b
I dunno, should work. Anyways, just write your own jvm exec task as I've done above
And drop application plugin
a
ok thanks for the help