Files

29 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Boot 4 split RestClient auto-configuration out of spring-boot-starter-webmvc: without
# spring-boot-starter-restclient there is no RestClient.Builder bean. This builds a throwaway copy
# of the app without that starter and captures the startup failure.
set -euo pipefail
source "$(dirname "$0")/lib.sh"
trap cleanup EXIT
mkdir -p "$OUT"
W="$ROOT/.tmp-norest"
rm -rf "$W" || true; mkdir -p "$W"
cp -r "$ROOT/app/src" "$W/src"
python3 - "$ROOT/app/pom.xml" "$W/pom.xml" <<'PY'
import re, sys
s = open(sys.argv[1]).read()
s = re.sub(r"\s*<dependency>\s*<groupId>org.springframework.boot</groupId>\s*<artifactId>spring-boot-starter-restclient</artifactId>\s*</dependency>", "", s, count=1)
open(sys.argv[2], "w").write(s)
PY
( cd "$W" && mvn -B -q -DskipTests package ) >/dev/null
{
echo "# 10 The same app built WITHOUT spring-boot-starter-restclient (Spring Boot 4.2.0)"
echo "# dependencies kept: spring-boot-starter-webmvc, -actuator, -jdbc, h2"
echo
# the JVM exits with status 1 on purpose here, so the pipeline's status is ignored
{ java -DPORT=$APP_PORT -jar "$W/target/orders-plain.jar" 2>&1 | grep -v 'Picked up' \
| sed -n '/APPLICATION FAILED TO START/,/Consider defining/p' | sed 's/^\*\*\*\*.*$/***************************/'; } || true
} > "$OUT/10-restclient-starter-missing.txt"
rm -rf "$W" || true
cat "$OUT/10-restclient-starter-missing.txt"