Files
spring-boot-demo/aot-cache/scripts/prepare.sh
T
Claude 3e2029ab3a Add aot-cache module: the JDK 25 AOT cache on Spring Boot 4.1 vs AppCDS, Spring AOT and GraalVM native
A Spring Boot 4.1.1 order service started 12 ways (plain and extracted jar, Spring AOT output, AppCDS, AOT cache trained with and without traffic, JDK 27, native image), ten interleaved rounds each, with first-request latency; 24 cache-mismatch cases; Docker layer arithmetic. Transcripts are in output/ (no docs/ folder).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TF9JWFvJSNm6HVzswzZU5a
2026-09-24 16:44:16 +00:00

33 lines
2.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds everything the measurements need under work/: the plain jar, a jar with Spring's own AOT output,
# the extracted layout, an AppCDS archive and the AOT caches. Prints what it built and how big each artifact is.
source "$(dirname "$0")/env.sh"
set -e
cd "$ROOT"
rm -rf "$WORK"; mkdir -p "$WORK"
echo "== build: plain jar (mvn package)"
rm -rf "$ROOT/target" # a stale target/ would carry Spring AOT output from an earlier -Pnative build into the plain jar
JAVA_HOME=$JDK25 mvn_run mvn -q -B -DskipTests package > "$WORK/build-plain.log" 2>&1
cp target/app.jar "$WORK/app.jar"
rm -rf "$ROOT/target"
echo "== build: jar with Spring AOT output (mvn -Pnative package; this does NOT compile a native image)"
JAVA_HOME=$JDK25 mvn_run mvn -q -B -DskipTests -Pnative package > "$WORK/build-springaot.log" 2>&1
cp target/app.jar "$WORK/app-springaot.jar"
echo "initializers in plain jar: $(unzip -l "$WORK/app.jar" | grep -c '__ApplicationContextInitializer')"
echo "initializers in Spring AOT jar: $(unzip -l "$WORK/app-springaot.jar" | grep -c '__ApplicationContextInitializer')"
echo "== extract both jars (java -Djarmode=tools -jar app.jar extract)"
"$JDK25/bin/java" -Djarmode=tools -jar "$WORK/app.jar" extract --destination "$WORK/ext" >/dev/null
"$JDK25/bin/java" -Djarmode=tools -jar "$WORK/app-springaot.jar" extract --destination "$WORK/ext-springaot" >/dev/null
mv "$WORK/ext-springaot/app-springaot.jar" "$WORK/ext-springaot/app.jar" # the launcher jar keeps its lib/ Class-Path
ls "$WORK/ext" "$WORK/ext-springaot"
echo "== build: the same service after a one-line change (the unit price in OrderService), for the mismatch and layer checks"
mkdir -p "$WORK/changed-src"
cp -r pom.xml src "$WORK/changed-src/"
sed -i 's/BigDecimal.valueOf(4_99, 2)/BigDecimal.valueOf(5_99, 2)/' "$WORK/changed-src/src/main/java/com/ankurm/aotcache/OrderService.java"
grep -n 'valueOf(5_99' "$WORK/changed-src/src/main/java/com/ankurm/aotcache/OrderService.java" | sed 's/^/edited: /'
( cd "$WORK/changed-src" && JAVA_HOME=$JDK25 mvn_run mvn -q -B -DskipTests package > "$WORK/build-changed.log" 2>&1 )
cp "$WORK/changed-src/target/app.jar" "$WORK/app-changed.jar"