37 runnable examples covering the eight feature posts on ankurm.com, verified against Jackson 3.2.1 on Temurin 21.0.5. Every output committed under docs/ was produced by run-all.sh. Also documents 11 places where the published snippets do not compile or do not behave as printed against a real Jackson 3 build - most notably that writeValueAsString(List<Base>) silently drops the polymorphic type discriminator, so the post's serialised output cannot be read back.
28 lines
968 B
Bash
Executable File
28 lines
968 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compiles the project and runs every example, writing each program's real output
|
|
# to docs/output/<ClassName>.txt. Everything checked into docs/output was produced
|
|
# by this script — nothing is hand-written.
|
|
set -u
|
|
cd "$(dirname "$0")"
|
|
|
|
mvn -B -q clean compile || { echo "compile failed"; exit 1; }
|
|
CP="target/classes:$(mvn -B -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout -DincludeScope=runtime 2>/dev/null | tail -1)"
|
|
mkdir -p docs/output
|
|
|
|
FAILED=0
|
|
for f in $(find src/main/java -name '*.java' | sort); do
|
|
CLASS=$(echo "$f" | sed 's|src/main/java/||; s|\.java$||; s|/|.|g')
|
|
grep -q 'public static void main' "$f" || continue
|
|
SHORT="${CLASS##*.}"
|
|
printf '%-52s' "$SHORT"
|
|
if java -cp "$CP" "$CLASS" > "docs/output/$SHORT.txt" 2>&1; then
|
|
echo "ok"
|
|
else
|
|
echo "FAILED"; FAILED=1
|
|
fi
|
|
done
|
|
|
|
echo
|
|
if [ "$FAILED" -eq 0 ]; then echo "All examples ran successfully."; else echo "Some examples failed."; fi
|
|
exit $FAILED
|