#!/usr/bin/env bash # Compiles each file in hibernate-data/src/broken/ on its own, inside a throwaway copy of the module, and records the # compiler's own message. Usage: scripts/broken.sh [ga|h8]. Needs JDK 25 and Maven. Writes hibernate-data/target/transcripts//05-compile-errors.txt set -uo pipefail cd "$(dirname "$0")/../hibernate-data" P="${1:-ga}" PFLAG=""; [ "$P" = "h8" ] && PFLAG="-Ph8" OUT="target/transcripts/$P"; mkdir -p "$OUT"; : > "$OUT/05-compile-errors.txt" for f in src/broken/*.java; do name=$(basename "$f" .java) tmp=$(mktemp -d) cp -r pom.xml src "$tmp/" # the parent pom is needed only for coordinates; make the copy standalone sed -i '//,/<\/parent>/d' "$tmp/pom.xml" sed -i 's#hibernate-data#com.ankurm1.0.0hibernate-data#' "$tmp/pom.xml" cp "$f" "$tmp/src/main/java/com/ankurm/data/" rm -rf "$tmp/src/broken" "$tmp/src/test" "$tmp/src/test-h8" [ -d "$tmp/src/h8" ] && [ "$P" != "h8" ] && rm -rf "$tmp/src/h8" echo "##### $name" >> "$OUT/05-compile-errors.txt" (cd "$tmp" && mvn -B -q $PFLAG compile 2>&1 | grep -E '^\[ERROR\] .*\.java:\[' | sed -E "s#$tmp/src/main/java/##; s#\[ERROR\] ##" | awk '!seen[$0]++') >> "$OUT/05-compile-errors.txt" rm -rf "$tmp" done cat "$OUT/05-compile-errors.txt"