Last active
July 5, 2022 06:27
-
-
Save nik-sta/21ce64680968b6b5f3bc0d5362e377a2 to your computer and use it in GitHub Desktop.
Production-ready Application Build Bash Script for layered Spring Boot Applications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| JAR_FILE=application.jar | |
| if [ ! -f "$JAR_FILE" ]; then | |
| echo "build.error: application jar is missing!" | |
| exit 1 | |
| fi | |
| jar xf application.jar | |
| REQUIRED_JAVA_MODULES="$(jdeps \ | |
| --print-module-deps \ | |
| --ignore-missing-deps \ | |
| --recursive \ | |
| --multi-release 17 \ | |
| --class-path="./BOOT-INF/lib/*" \ | |
| --module-path="./BOOT-INF/lib/*" \ | |
| ./application.jar)" | |
| if [ -z "$REQUIRED_JAVA_MODULES" ]; then | |
| echo "build.error: required java modules are not determined!" | |
| exit 1 | |
| fi | |
| jlink \ | |
| --no-header-files \ | |
| --no-man-pages \ | |
| --compress 2 \ | |
| --add-modules "${REQUIRED_JAVA_MODULES}" \ | |
| --output /opt/java-runtime | |
| java -Djarmode=layertools -jar application.jar extract | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment