aboutsummaryrefslogtreecommitdiffstats
path: root/build.sh
diff options
context:
space:
mode:
authorKostya <mail@sartin.in>2026-07-26 18:29:52 +0300
committerKostya <mail@sartin.in>2026-07-26 18:29:52 +0300
commitb9c9c4f21cb8b40b240593e240754d5bce54a023 (patch)
treec3390a0c37332b0bf7b2049f3de13cd1f900629d /build.sh
parent325d40e9bcc54d3389450fb951c873ffb466bb64 (diff)
downloadjava-bootstrap-b9c9c4f21cb8b40b240593e240754d5bce54a023.tar.gz
java-bootstrap-b9c9c4f21cb8b40b240593e240754d5bce54a023.tar.xz
java-bootstrap-b9c9c4f21cb8b40b240593e240754d5bce54a023.zip
fix build scriptsHEADmaster
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh48
1 files changed, 24 insertions, 24 deletions
diff --git a/build.sh b/build.sh
index ca768c4..6fdf7e1 100755
--- a/build.sh
+++ b/build.sh
@@ -3,23 +3,26 @@ set -e
3 3
4echo "=== 1. Cleaning Workspace ===" 4echo "=== 1. Cleaning Workspace ==="
5rm -rf bin stage 5rm -rf bin stage
6mkdir bin bin/classes bin/test-classes stage 6mkdir -p bin/classes bin/test-classes stage dist # dist was never created
7 7
8echo "=== 2. Compiling Production Code ===" 8echo "=== 2. Compiling Production Code ==="
9javac -d bin/classes -cp "lib/*" src/main/java/com/example/App.java 9javac -d bin/classes -cp "lib/*" @<(find src/main/java -name '*.java')
10 10
11echo "=== 3. Compiling Test Code ===" 11echo "=== 3. Compiling Test Code ==="
12javac -d bin/test-classes -cp "bin:lib/*" src/test/java/com/example/AppTest.java 12# prod classes are in bin/classes, not bin
13javac -d bin/test-classes -cp "bin/classes:lib/*" @<(find src/test/java -name '*.java')
13 14
14echo "=== 4. Running Automated Tests ===" 15echo "=== 4. Running Automated Tests ==="
15JUNIT_JAR=$(find lib/junit-platform-console-standalone-*.jar | head -n 1) 16JUNIT_JAR=$(find lib -maxdepth 1 -name 'junit-platform-console-standalone-*.jar' | head -n 1)
16if [ -z "$JUNIT_JAR" ]; then 17if [ -z "$JUNIT_JAR" ]; then
17 echo "JUnit jar missing." 18 echo "JUnit jar missing."
18 exit 1 19 exit 1
19fi 20fi
20 21
21set +e 22set +e
22java -jar "$JUNIT_JAR" execute -cp "bin:lib/*" --scan-classpath 23java -jar "$JUNIT_JAR" execute \
24 -cp "bin/classes:bin/test-classes:lib/*" \
25 --scan-classpath
23TEST_STATUS=$? 26TEST_STATUS=$?
24set -e 27set -e
25 28
@@ -32,30 +35,27 @@ echo "✅ Tests passed successfully!"
32echo "=== 5. Extracting Dependencies for Fat JAR ===" 35echo "=== 5. Extracting Dependencies for Fat JAR ==="
33cd stage 36cd stage
34for jarfile in ../lib/*.jar; do 37for jarfile in ../lib/*.jar; do
35 echo "$jarfile" 38 [ -f "$jarfile" ] || continue
36 # Skip the JUnit jar so we don't bloat production code 39 case "$(basename "$jarfile")" in
37 if [[ "$jarfile" == *"junit-platform-console-standalone"* ]]; then 40 junit-platform-console-standalone-*) continue ;;
38 continue 41 esac
39 fi 42 echo "Extracting: $(basename "$jarfile")"
40 if [ -f "$jarfile" ]; then 43 jar -xf "$jarfile"
41 echo "Extracting: $(basename "$jarfile")"
42 jar -xf "$jarfile"
43 fi
44done 44done
45# Clean up extracted manifest directories to prevent conflicts 45
46rm -rf META-INF 46# Strip signatures + manifests (they break repacking), but KEEP
47# META-INF/services so ServiceLoader-based deps still work at runtime.
48find META-INF -type f \( -name '*.SF' -o -name '*.RSA' -o -name '*.DSA' -o -name 'MANIFEST.MF' \) -delete 2>/dev/null || true
47cd .. 49cd ..
48 50
49echo "=== 6. Merging Assets into Fat JAR ===" 51echo "=== 6. Merging Assets into Fat JAR ==="
50# Copy your own compiled production classes into the staging folder 52# Merge YOUR production classes on top of the extracted deps
51cp -r bin/* stage/ 53cp -r bin/classes/. stage/
52 54# Package the whole tree (deps + your classes), not just stage/classes
53# Package everything in the staging area into the final JAR 55jar cfe dist/app.jar com.example.App -C stage .
54jar cfe dist/app.jar com.example.App -C stage/classes/ .
55 56
56# Clean up staging area
57rm -rf stage 57rm -rf stage
58echo "======================================" 58echo "======================================"
59echo "🎉 Fat JAR Created! Run it anywhere using:" 59echo "🎉 Fat JAR Created! Run it with:"
60echo "java -jar app.jar" 60echo "java -jar dist/app.jar"
61echo "======================================" 61echo "======================================"