From 816258fe6f5644172de2657b2abf2fe9f18746dc Mon Sep 17 00:00:00 2001 From: Jonathan Schneider Date: Tue, 25 Aug 2026 05:21:52 -0400 Subject: [PATCH] Name a `ChangeDependency` instance by the coordinates it changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both recipes this one delegates to already do this. `ChangeDependencyGroupIdAndArtifactId` and Gradle's `ChangeDependency` each render `` `oldGroupId:oldArtifactId` `` as their instance name suffix, so the unified recipe was the only one of the three that fell back to a bare display name. The default `getInstanceName()` interpolates an option only when exactly one is required. This recipe requires two, so every instance came out as "Change Gradle or Maven dependency" regardless of what it changed. A composite that lists several of them — the Spring Boot 4.0 migration lists seven — reads as the same line repeated, in the recipe list and in the `SourcesFileResults` and `RecipeRunStats` data tables alike. --- .../java/dependencies/ChangeDependency.java | 5 +++++ .../java/dependencies/ChangeDependencyTest.java | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/org/openrewrite/java/dependencies/ChangeDependency.java b/src/main/java/org/openrewrite/java/dependencies/ChangeDependency.java index 28bf5eb4..c761debd 100644 --- a/src/main/java/org/openrewrite/java/dependencies/ChangeDependency.java +++ b/src/main/java/org/openrewrite/java/dependencies/ChangeDependency.java @@ -89,6 +89,11 @@ public class ChangeDependency extends ScanningRecipe validate(ExecutionContext ctx) { return super.validate(ctx) diff --git a/src/test/java/org/openrewrite/java/dependencies/ChangeDependencyTest.java b/src/test/java/org/openrewrite/java/dependencies/ChangeDependencyTest.java index d8dc3370..22cf3019 100644 --- a/src/test/java/org/openrewrite/java/dependencies/ChangeDependencyTest.java +++ b/src/test/java/org/openrewrite/java/dependencies/ChangeDependencyTest.java @@ -293,4 +293,14 @@ void pinWhenOverrideManagedVersionGradle() { ) ); } + + @Test + void instanceName() { + // A composite recipe lists many ChangeDependency instances, and without the coordinates + // in the name they are indistinguishable from one another. + ChangeDependency cd = new ChangeDependency("org.springframework.boot", "spring-boot-starter-web", + null, "spring-boot-starter-webmvc", "4.0.x", null, null, null); + assertThat(cd.getInstanceName()) + .isEqualTo("Change Gradle or Maven dependency `org.springframework.boot:spring-boot-starter-web`"); + } }