hey there! Is there any clean way to get executabl...
# multiplatform
k
hey there! Is there any clean way to get executable JAR of an application build with Kotlin MP? I've found a ticket here with some solution: https://youtrack.jetbrains.com/issue/KT-50227/MPP-JVM-target-executable-application which seems to be Open so started wondering if there's any other approach. Is anyone here aware of any other solution to this?
s
Does executable JAR mean a standalone excutable bundle similar to` .exe` or
.app
or
.dmg
in mac?
k
yes, basically an equivalent of
.kexe
which can be easily exported by
binaries.executable()
available for Native
c
If your goal is to have an archive with the Java executable, the
application
plugin can generate it easily: https://gitlab.com/opensavvy/notes/kotlin-fullstack/-/blob/main/app-cli/build.gradle.kts?ref_type=heads Note the: •
application
in the
plugins
block • the
jvm { withJava() }
block (mandatory, but not documented anywhere!) • the
application
block with the main class The plugin generates either a
.zip
or
.tar.gz
which contains a script that starts the application. It's not a single executable JAR, but in my case that was what I was searching for.
👀 1
👍 1
k
looks promising, will give it a try, thanks!
s
You can also create native distributions like
.exe
,
.app
k
this one is applicable to Compose MP I believe
s
Yes, you are correct
s
also something like shadowjar (https://github.com/johnrengelman/shadow can be used, if you want to produce a single shaded jar with all your dependencies. here are a few non-multiplatform examples: • https://github.com/PolyhedralDev/BiomeTool/blob/master/build.gradle.kts#L164-L185https://github.com/solo-studios/PolyBot/blob/feature/plugins/build.gradle.kts#L235-L264
👀 1