#!/usr/bin/env bash # Does spring-boot-configuration-processor actually run? # # Two builds of the SAME sources with the SAME processor jar, differing only in how the # processor is declared to the compiler. On JDK 23+ that difference decides whether # META-INF/spring-configuration-metadata.json exists at all -- and neither build fails. set -euo pipefail cd "$(dirname "$0")/.." source scripts/env.sh WORK="${TMPDIR:-/tmp}/configprops-metadata-ab" rm -rf "$WORK"; mkdir -p "$WORK/a" "$WORK/b" PROC_JAR=$(find ~/.m2/repository/org/springframework/boot/spring-boot-configuration-processor \ -name 'spring-boot-configuration-processor-*.jar' | sort | tail -1) CP=$("$MVN" -B -o -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout 2>/dev/null | tail -1) SOURCES=$(find src/main/java -name '*.java') { echo "== is the annotation processor discovered? ==" echo java -version 2>&1 | clean | head -1 echo "processor jar: $(basename "$PROC_JAR")" echo echo "A) processor on the classpath, javac defaults -- what an dependency gives you" echo "\$ javac -cp :spring-boot-configuration-processor.jar -d a \$SOURCES" javac -nowarn -cp "$PROC_JAR:$CP" -d "$WORK/a" $SOURCES 2>&1 | clean | head -3 || true echo " spring-configuration-metadata.json files produced: \ $(find "$WORK/a" -name 'spring-configuration-metadata.json' | wc -l)" echo echo "B) identical, plus -proc:full" echo "\$ javac -proc:full -cp :spring-boot-configuration-processor.jar -d b \$SOURCES" javac -nowarn -proc:full -cp "$PROC_JAR:$CP" -d "$WORK/b" $SOURCES 2>&1 | clean | head -3 || true echo " spring-configuration-metadata.json files produced: \ $(find "$WORK/b" -name 'spring-configuration-metadata.json' | wc -l)" echo echo "Both compilations succeed. Only one of them has metadata." echo echo "== what this project's pom does instead ==" echo "The processor is declared as an on maven-compiler-plugin," echo "which puts it on javac's --processor-path where discovery is not disabled:" echo echo "\$ mvn clean package && ls target/classes/META-INF/" ls target/classes/META-INF/ 2>/dev/null || echo "(run mvn package first)" echo echo "== the generated metadata, first entries ==" python3 -m json.tool target/classes/META-INF/spring-configuration-metadata.json 2>/dev/null \ | head -45 } > docs/output/05-metadata-generation.txt 2>&1 cat docs/output/05-metadata-generation.txt