Files

24 lines
1.3 KiB
Bash
Executable File

#!/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/<profile>/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>/,/<\/parent>/d' "$tmp/pom.xml"
sed -i 's#<artifactId>hibernate-data</artifactId>#<groupId>com.ankurm</groupId><version>1.0.0</version><artifactId>hibernate-data</artifactId>#' "$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"