Add resttemplate-to-restclient module: RestTemplate deprecation on Spring Framework 7.1 / Boot 4.2.0 vs 4.1.3, method mapping, exchange() trap, bridge URI encoding, RestTestClient, OpenRewrite recipe run, with real transcripts

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7M7FEdeEm3APj16Bu
This commit is contained in:
Claude
2026-11-21 21:26:48 +05:30
parent 5f85ec8d53
commit cbcfb05e35
77 changed files with 2187 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Runs the Moderne recipe io.moderne.java.spring.boot3.MigrateRestTemplateToRestClient
# (io.moderne.recipe:rewrite-spring 0.40.1, plugin rewrite-maven-plugin 6.46.1) on
# src/recipe/before/RemoteClient.java in a scratch project OUTSIDE this checkout (OpenRewrite
# silently skips git-ignored sources), stores the diff in output/20-openrewrite-diff.txt and
# copies the generated class to src/test/.../recipe/RemoteClient.java, where RecipeOutputTest runs it.
set -euo pipefail
cd "$(dirname "$0")/.."
HERE=$(pwd)
W=$(mktemp -d)
mkdir -p "$W/src/main/java/com/ankurm/rtmigration/recipe"
cat > "$W/pom.xml" <<'P'
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>4.2.0</version><relativePath/></parent>
<groupId>demo</groupId><artifactId>orw</artifactId><version>1.0.0</version>
<properties><java.version>25</java.version></properties>
<dependencies>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webmvc</artifactId></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-restclient</artifactId></dependency>
</dependencies>
</project>
P
cp src/main/java/com/ankurm/rtmigration/Student.java "$W/src/main/java/com/ankurm/rtmigration/" 2>/dev/null || { mkdir -p "$W/src/main/java/com/ankurm/rtmigration"; cp src/main/java/com/ankurm/rtmigration/Student.java "$W/src/main/java/com/ankurm/rtmigration/"; }
cp src/recipe/before/RemoteClient.java "$W/src/main/java/com/ankurm/rtmigration/recipe/"
( cd "$W" && git init -q . && git add -A && git -c user.email=a@b -c user.name=n commit -qm before
mvn -B -q org.openrewrite.maven:rewrite-maven-plugin:6.46.1:run \
-Drewrite.recipeArtifactCoordinates=io.moderne.recipe:rewrite-spring:0.40.1 \
-Drewrite.activeRecipes=io.moderne.java.spring.boot3.MigrateRestTemplateToRestClient 2>&1 | { grep -v -E '^Picked|^WARNING' || true; } | tail -5
{ echo "# 20-openrewrite-diff (io.moderne.recipe:rewrite-spring 0.40.1, rewrite-maven-plugin 6.46.1, Spring Boot 4.2.0)"
echo "\$ mvn rewrite:run -Drewrite.activeRecipes=io.moderne.java.spring.boot3.MigrateRestTemplateToRestClient"
git diff -U0 | grep -v -E '^(diff|index|---|\+\+\+)'; } > "$HERE/output/20-openrewrite-diff.txt" )
cp "$W/src/main/java/com/ankurm/rtmigration/recipe/RemoteClient.java" src/test/java/com/ankurm/rtmigration/recipe/RemoteClient.java
rm -rf "$W"
cat output/20-openrewrite-diff.txt