Example build.gradle.kt to build a shadow jar for java and kotlin application | Fat Jar In Kotlin DSL
If you need an all in one Jar (Fat Jar) in Gradle with the Kotlin DSL syntax, Here is an example of how you can build a shadow jar for both java and kotlin application.
Difference between Java vs Kotlin App
If you are building kotlin spring-boot application using gradle kotlin dsl and your main class file is MyApp.kt
plugins { id("org.jetbrains.kotlin.plugin.spring").version("1.3.61") ... } ... manifest { attributes(mapOf("Main-Class" to "com.myproject.MyAppKt")) }
If you are building Java application using gradle kotlin dsl and your main class file is MyApp.java
plugins { java ... } ... manifest { attributes(mapOf("Main-Class" to "com.myproject.MyApp")) }
I am a beginner in java/kotlin as well. If you think something is missing or can be improved please let me know in the comment below.
Why We need to use 'isZip64 = true' ?
If your project is big and have lot's file files, maybe more than 65K files then you might end up getting error like below if you don't use this
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':abc:ShadowJar'. org.apache.tools.zip.Zip64RequiredException: archive contains more than 65535 entries. To build this archive, please enable the zip64 extension. See: http://gradle.org/docs/2.1/dsl/org.gradle.api.tasks.bundling.Zip.html#org.gradle.api.tasks.bundling.Zip:zip64 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED
If it's going to be a big project, I would prefer to use
isZip64 = true
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.