@@ -2621,6 +2621,103 @@ void sharedPropertyInParentPomUsedByDifferentChildrenLeavesPropertyUnchanged() {
26212621 );
26222622 }
26232623
2624+ @ Issue ("https://github.com/openrewrite/rewrite/pull/6630#issuecomment-3873627052" )
2625+ @ Test
2626+ void childRedefinesPropertyUsedNonConflictinglyInlinesVersionInParent () {
2627+ // When a child redefines a parent property and uses it for a non-matching dependency,
2628+ // the parent property is not updated even though the child would not be affected.
2629+ // This is overly conservative but safe: ChangePropertyValue via doAfterVisit does not
2630+ // scope to a single document, so it would also change the child's redefined property.
2631+ rewriteRun (
2632+ spec -> spec .recipe (new ChangeDependencyGroupIdAndArtifactId (
2633+ "io.swagger" ,
2634+ "swagger-annotations" ,
2635+ "io.swagger.core.v3" ,
2636+ null ,
2637+ "2.2.x" ,
2638+ null ,
2639+ null ,
2640+ null
2641+ )),
2642+ mavenProject ("project" ,
2643+ pomXml (
2644+ //language=xml
2645+ """
2646+ <project>
2647+ <groupId>com.mycompany.app</groupId>
2648+ <artifactId>parent-project</artifactId>
2649+ <version>1</version>
2650+ <properties>
2651+ <version.swagger>1.5.16</version.swagger>
2652+ </properties>
2653+ <modules>
2654+ <module>sub-project</module>
2655+ </modules>
2656+ <dependencies>
2657+ <dependency>
2658+ <groupId>io.swagger</groupId>
2659+ <artifactId>swagger-annotations</artifactId>
2660+ <version>${version.swagger}</version>
2661+ </dependency>
2662+ </dependencies>
2663+ </project>
2664+ """ ,
2665+ //language=xml
2666+ """
2667+ <project>
2668+ <groupId>com.mycompany.app</groupId>
2669+ <artifactId>parent-project</artifactId>
2670+ <version>1</version>
2671+ <properties>
2672+ <version.swagger>1.5.16</version.swagger>
2673+ </properties>
2674+ <modules>
2675+ <module>sub-project</module>
2676+ </modules>
2677+ <dependencies>
2678+ <dependency>
2679+ <groupId>io.swagger.core.v3</groupId>
2680+ <artifactId>swagger-annotations</artifactId>
2681+ <version>2.2.42</version>
2682+ </dependency>
2683+ </dependencies>
2684+ </project>
2685+ """ ,
2686+ spec -> spec .path ("pom.xml" )
2687+ ),
2688+ mavenProject ("sub-project" ,
2689+ pomXml (
2690+ //language=xml
2691+ """
2692+ <project>
2693+ <groupId>com.mycompany.app</groupId>
2694+ <artifactId>sub-project</artifactId>
2695+ <version>1</version>
2696+ <parent>
2697+ <groupId>com.mycompany.app</groupId>
2698+ <artifactId>parent-project</artifactId>
2699+ <version>1</version>
2700+ <relativePath>../pom.xml</relativePath>
2701+ </parent>
2702+ <properties>
2703+ <version.swagger>1.5.17</version.swagger>
2704+ </properties>
2705+ <dependencies>
2706+ <dependency>
2707+ <groupId>io.swagger</groupId>
2708+ <artifactId>swagger-models</artifactId>
2709+ <version>${version.swagger}</version>
2710+ </dependency>
2711+ </dependencies>
2712+ </project>
2713+ """ ,
2714+ spec -> spec .path ("sub-project/pom.xml" )
2715+ )
2716+ )
2717+ )
2718+ );
2719+ }
2720+
26242721 @ Issue ("https://github.com/openrewrite/rewrite/issues/5965" )
26252722 @ Test
26262723 void changeDependencyGroupIdAndArtifactIdForEjbType () {
0 commit comments