I'm trying to setup a multiplatform application pr...
# multiplatform
d
I'm trying to setup a multiplatform application project but I can't figure out how to (nicely) get the generated jar to execute it. In the native case there's
kotlin.targets.mingw.compilations.main.getBinary('EXECUTABLE', buildType)
to get the binary for execution. What is the jvm equivalent?
kotlin.targets.jvm.compilations.main.getJar('EXECUTABLE', buildType)
doesn't work 🙂.
Ah! Found it. It's
jvmJar.archivePath
or at least it's close enough.
Couldn't run the jar. I got
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
. Not sure how to add kotlin-runtime to classpath in this setup. 😞
r
You should not just run one jar, but form claasspath based on runtime configuration from Gradle -- it would have your classes and your dependencies. I'll try to remember to get back to you as soon as I get to office, if you or someone else doesn't provide Gradle snippet to do in.
d
Thank you! 😊
h
Here's a snippet I use to run one the classes of a JVM target with a Gradle task:
Copy code
task run(type: JavaExec) {
    main = 'com.my.entry.Point'
    def target = kotlin.targets.jvm
    def compilation = target.compilations.main

    classpath = files(
        compilation.runtimeDependencyFiles,
        compilation.output.allOutputs
    )
}
👍 2
r
Yeah, I had something along those lines too. @Dominaezzz by the way, there is an issue for having this out of the box, you can follow it if you wish: https://youtrack.jetbrains.com/issue/KT-27273