Files

26 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Reproduces the failure you get when Spring Boot's BOM wins and Kotlin stays on 1.9.25.
# Run from the repository root after `mvn test -pl koog` (needs koog/target/test-classes).
set -eu
cd "$(dirname "$0")/.."
OUT=output/07-kotlin-bom-trap.txt
mvn -B -q dependency:build-classpath -Dmdep.outputFile=target/cp.txt >/dev/null 2>&1
mvn -B -q dependency:get -Dartifact=org.jetbrains.kotlin:kotlin-stdlib:1.9.25 >/dev/null 2>&1
OLD="$HOME/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.9.25/kotlin-stdlib-1.9.25.jar"
good="$(cat target/cp.txt)"
bad="$(echo "$good" | tr ':' '\n' | sed "s#.*/kotlin-stdlib-2\.3\.10\.jar#$OLD#" | tr '\n' ':')"
{
echo "kotlin-stdlib on the classpath (correct, Kotlin BOM imported first):"
echo "$good" | tr ':' '\n' | grep -o 'kotlin-stdlib-[0-9.]*\.jar' | sed 's/^/ /'
echo
echo "Same classpath with kotlin-stdlib 1.9.25, which is what the Spring Boot 3.5.16 BOM picks when it comes first:"
echo "$bad" | tr ':' '\n' | grep -o 'kotlin-stdlib-[0-9.]*\.jar' | sed 's/^/ /'
echo
echo '$ java -cp <that classpath> com.ankurm.koog.TrapMain'
java -cp "target/test-classes:target/classes:$bad" com.ankurm.koog.TrapMain 2>&1 \
| grep -vE 'SLF4J|Picked up|kotlin-logging' | head -4 | sed 's/^/ /'
} > "$OUT"
cat "$OUT"