janvladimirmostert
05/11/2022, 7:57 PMgradle shadowJar
, but only getting a jar with a Manifest in it
in my root build.gradle.kts
, I have the shadow plugin
plugins {
...
val shadowVersion = "7.1.2"
kotlin("multiplatform").version(kotlinVersion).apply(false)
kotlin("plugin.serialization").version(kotlinVersion).apply(false)
id("com.github.johnrengelman.shadow").version(shadowVersion).apply(false)
}
and then in my module
plugins {
application
kotlin("plugin.serialization")
kotlin("multiplatform")
id("com.github.johnrengelman.shadow")
}
application {
mainClass.set("com.blah.MyServer")
}
when running gradle shadowJar
, I get a fatjar which only contains a manifest, nothing else, not even a class file, but when hitting run in IntelliJ, it runs perfectly fine.
my jvm files are under module/src/jvmMain/kotlin/com/blah/*.kt
what is the alternative to build fat jars?
I've tried the zipping approach, but it too is doing the same
tasks.named<Jar>("jar") {
archiveFileName.set("foo.jar")
manifest {
attributes("Main-Class" to "com.blah.MyServer")
}
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from ({
configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) }
})
}
ephemient
05/11/2022, 8:17 PMephemient
05/11/2022, 8:21 PMjanvladimirmostert
05/12/2022, 5:30 AMjvm {
compilations.all {
kotlinOptions.jvmTarget = "17"
}
withJava()
}