Uber JAR with Gradle Kotlin DSL
What's inside this article
⌄
- Gradle Kotlin DSL uber JAR
- How to build fat JAR Gradle Kotlin
- Gradle Kotlin create uber JAR
- Gradle Kotlin shadow JAR
- How to make an uber jar Gradle Kotlin DSL
- How to make a fat jar Gradle Kotlin DSL
Let’s add this to build.gradle.kts file:
tasks.register<Jar>("uberJar") {
archiveClassifier.set("uber")
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
})
}
After that, you can build the jar with dependencies:
./gradlew uberJar
Possible errors
No main manifest attribute
Error: no main manifest attribute, in /path/to/your/jar
You need to add a key to your manifest containing the full name of the main class. See this article.
Invalid signature file digest
Error: Invalid signature file digest for Manifest main attributes.
You need to exclude files with extensions .SF, .DSA, .RSA from the assembly.
See this article.