WARNING: This plugin is no longer under active development. Please, migrate to Gradle Shadow Plugin which provides similar functionality.
Gradle FatJar Plugin allows you to create JAR file with all dependencies bundled inside. It handles files in META-INF/services
directory gracefully by merging them. It also allows you to create slim WAR file which contains only JAR with dependencies.
Classes are also bundled into the JAR instead of putting them into WEB-INF/classes.
Plugin is hosted on Bintray. You can easily add plugin to your build script using following configuration
Note: regular jar and war tasks are not replaced by this plugin. You can still use them.
Don't forget that you need to configure fatJar and slimWar tasks if you want to modify generated
manifest or exclude files not jar or war ones.
fatJarPrepareFiles
Explodes all JARs into the stage directory and merges all files needed such as those in META-INF/services.
fatJar
Creates the JAR with all dependencies bundled.
This is regular Jar task so you can e.g. customize the manifest as
described in Jar Task DSL.
You can for example exclude files from being jared.
fatJar {
exclude 'META-INF/*.DSA'
}
slimWar
Bundles all output classes into JAR with dependencies and place it into WEB-INF/lib directory of the newly created
WAR file.
This is regular War task so you can e.g. customize the web.xml file as
described in War Task DSL.
You can for example exclude files which you don't want to copy into the final WAR.
If you need to keep some JARs out of the JAR with dependencies you can specify extended property fatJarExclude on
particular dependency. All excluded JARs will be placed in WEB-INF\lib directory if slimWar task is called.
请发表评论