📅  最后修改于: 2023-12-03 15:31:03.690000             🧑  作者: Mango
GradleW is a build automation tool that is designed to be flexible, scalable, and efficient and it's used for building Java applications. ‘make jar’ is one of the most popular GradleW tasks used by Java developers for creating Jar files.
To use ‘make jar’ task, open your command prompt or terminal, navigate to the project directory, and type the following command.
./gradlew make jar
This will compile your code and create a jar file in the build directory.
Custom Jar name: You can give your jar file a custom name by specifying the name in the build.gradle file.
jar {
archiveName 'myCustomName.jar'
}
Excluding files from Jar: You may want to exclude certain files from your Jar, you can do so by updating the build.gradle file as shown below.
jar {
exclude 'README.md'
}
Including files in Jar: Similarly, you might want to include files that are not included by default. You can include additional files like so.
jar {
from 'src/main/resources'
}
In conclusion, ‘make jar’ is a useful and essential GradleW task for Java developers. It allows them to compile their code and package it as a Jar file for easy distribution. With the added advanced features, users can further customize their Jar files for better functionality.
./gradlew make jar
jar {
archiveName 'myCustomName.jar'
exclude 'README.md'
from 'src/main/resources'
}