Bundling up the application as a runnable JAR file
We've hacked out a suitable application. Now it's time to take it to production. As Spring Developer Advocate Josh Long likes to say, production is the happiest place on earth.
The good ol' spring-boot-gradle-plugin
has built-in hooks to handle that for us. By invoking Gradle's build
task, it will insert itself into the build process, and create a JAR file.
$ ./gradlew clean build:clean:compileJava:processResources:classes:findMainClass:jar:bootRepackage:assemble:compileTestJava:processTestResources UP-TO-DATE:testClasses:test... test output ...:check:buildBUILD SUCCESSFULTotal time: 10.946 secs
If we peek at the output, we'll find the original JAR file (non-FAT) along with the rebundled one containing our application code as well as the third-party dependencies, as shown here:
$ ls build/libslearning-spring-boot-0.0.1-SNAPSHOT.jarlearning-spring-boot-0.0.1-SNAPSHOT.jar.original
Note
If you wish to check out the newly minted JAR's contents, type...