Skip to content

ChangeParentPom incorrectly updates child module after update #7307

@tschut

Description

@tschut

When upgrading the external parent pom of a multi-module project, it looks like the changes aren't properly propagated when UpdateMavenModel runs.

Example project https://github.com/tschut/openrewrite-revision-bug

Reproduction steps:

  1. Check out the above repo
  2. run mvn -U org.openrewrite.maven:rewrite-maven-plugin:run --define rewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE --define rewrite.activeRecipes=org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0
  3. you'll see an added dependency:
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-flyway</artifactId>
            <version>4.0.5</version>
        </dependency>

The explicit version <version>4.0.5</version> is unexpected, as that version is managed by Spring Boot.

We've debugged this quite a bit, and it looks like UpdateMavenModel runs multiple times. First it runs for the root pom.xml, which correctly uses spring-boot-starter-parent:4.0.5. After that, it runs for app/pom.xml, which appears to not use the updated grandparent, but uses the old version for spring-boot-starter-parent.

Note that in this reproducer project the issue seems to be not very bad (it's just an explicit version you don't need), but in particular with all the new modules in Spring Boot 4 the issue in a real world project could be very annoying.

Perhaps a regression on

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions