Create a Fat JAR with Gradle
Jump to navigation
Jump to search
External
Internal
Overview
A "fat" JAR, or an uber-JAR, is a self-sufficient archive which contains both classes and dependencies needed to run an application. It is also configured with a Main-Class attribute. The Gradle Java plugin creates "thin" JARs. However, it can be configured to create a "fat" JAR. Specialized plugins are also available.
Creating a Fat JAR with the Jar Task from the Java Plugin
jar {
manifest {
attributes "Main-Class": "com.example.Application"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
Creating a Fat JAR with the Shadow Plugin
Not tested.