📅  最后修改于: 2023-12-03 14:41:37.525000             🧑  作者: Mango
Gradle FatJar is a plugin for Gradle that creates a single executable jar file containing all dependencies and resources required by the application. This is useful when deploying the application to a server or distributing it to other users.
To use the Gradle FatJar plugin, you will need to add it to your Gradle build file.
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.0.0'
}
The java
plugin is used to build the application and the com.github.johnrengelman.shadow
plugin is used to create the FatJar.
Once the plugin is added to the build file, you can configure it as follows:
shadowJar {
baseName = 'my-application'
version = '1.0.0'
manifest {
attributes 'Main-Class': 'com.example.MyApplication'
}
}
The baseName
is the name of the FatJar file and the version
is the version number. The manfiest
block is used to specify the main class of the application.
To build the FatJar, you can use the following command:
./gradlew shadowJar
This will create a FatJar file in the build/libs
directory.
The Gradle FatJar plugin is a useful tool for packaging Java applications for deployment or distribution. It simplifies the process of managing dependencies and resources and makes it easier to distribute the application to other users.