Skip to content

Update Java version properties redefined in an intermediate parent pom - #8413

Merged
timtebeek merged 1 commit into
mainfrom
tim/java-version-property-nested-parent
Aug 6, 2026
Merged

Update Java version properties redefined in an intermediate parent pom#8413
timtebeek merged 1 commit into
mainfrom
tim/java-version-property-nested-parent

Conversation

@timtebeek

Copy link
Copy Markdown
Member

What's changed?

UpdateMavenProjectPropertyJavaVersion returns early when the parent pom is part of the same project, on the assumption that the property will be updated there. That assumption breaks when the module redefines the property itself: the local value shadows the parent's, so the module (and every module inheriting from it) stays on the old Java version.

This shows up in projects that keep a dedicated parent pom as a module of the aggregator pom, with both the aggregator and the parent declaring <java.version>. Only the aggregator was updated; the parent pom that all other modules actually inherit from kept its old value.

Now any of the Java version properties declared in the pom itself is updated, instead of only those referenced by a source/target/release in the parent's maven-compiler-plugin configuration. That earlier special case is a subset of this, so it's been folded in. Properties that are merely inherited are still left alone, so no new properties are added to child modules.

Anything in particular you'd like reviewers to focus on?

Whether updating an explicitly redefined property is always desired, or whether a module deliberately pinning a lower Java version should be left alone.

Have you considered any alternatives or workarounds?

Keeping the early return and widening only the plugin-configuration special case, but the property shadowing is what matters here, not how the parent happens to consume it.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions

A pom that redefines one of the Java version properties shadows the value
inherited from its parent, so updating only the parent leaves that module
and everything below it on the old Java version. Update any Java version
property declared in the pom itself, rather than only those referenced by
the parent's maven-compiler-plugin configuration.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Aug 6, 2026
@timtebeek
timtebeek marked this pull request as ready for review August 6, 2026 22:46
@timtebeek
timtebeek merged commit b3f7568 into main Aug 6, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/java-version-property-nested-parent branch August 6, 2026 23:38
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant