I've got an old project that I'm trying to migrate over to use the new experimental jvm binaries DSL...
d
I've got an old project that I'm trying to migrate over to use the new experimental jvm binaries DSL, and although I'm essentially writing code identical to the example at https://kotl.in/jvm-binaries-dsl it doesn't seem to pick up the main class I'm setting.
My build script so far in its entirety is:
Copy code
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
    alias(libs.plugins.kotlin.multiplatform)
}

group = "dev.bitspittle.kross2d.examples.sprite"
version = "0.0.1"

kotlin {
    @OptIn(ExperimentalKotlinGradlePluginApi::class)
    jvm { binaries { executable { mainClass.set("SpriteRunnerKt") } } }
    js { browser { binaries.executable() } }
    sourceSets {
        commonMain.dependencies {
            api("dev.bitspittle.kross2d:kross2d")
        }
    }
}
where
libs.version.toml
is:
Copy code
[versions]
kotlin = "2.2.10"

[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
so, nothing crazy.
SpriteRunner.kt does indeed exist in jvmMain at the top level and looks like this:
Copy code
import dev.bitspittle.kross2d.core.math.Vec2
import dev.bitspittle.kross2d.engine.app.AppParams
import dev.bitspittle.kross2d.engine.app.launch

fun main() {
    val screenSize = Vec2(640, 480)
    launch(
        AppParams("Sprite", screenSize),
        initialState = SpriteState())
}
When I run
./gradlew :sprite:jvmRun
however, I get:
Copy code
Execution failed for task ':sprite:jvmRun'.
> No main class specified and classpath is not an executable jar.
But when I run
./gradlew :sprite:jvmRun -DmainClass=SpriteRunnerKt
, it works fine.
I'm not in a great place to upload the code, and it's very late here, so I can do this tomorrow if necessary. But since what I'm running into is so basic, I'm wondering if I'm just understanding the fundamental feature wrong?
t
you are using the wrong task name - it should be
runJvm
- see this issue
🤦‍♂️ 1
thank you color 1
d
OMG 😄 Yahor, do you know if someone at JetBrains can add a line to the docs (https://kotl.in/jvm-binaries-dsl) that warns people against using the legacy "jvmRun" task, perhaps even linking to KT-75240 for more information?
👌 1
m
@David Herman FWIW, most of the Kotlin docs (all?) are open source. You can send a PR here, they are usually triaged in a few days
v
I wish that would be true for code changes, my PR waits since 7 months :-(
1
d
❤️ 1