Update Java version properties redefined in an intermediate parent pom - #8413
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed?
UpdateMavenProjectPropertyJavaVersionreturns 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/releasein the parent'smaven-compiler-pluginconfiguration. 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