Skip to content

Allow overriding Maven plugin versions managed by external parents - #8779

Closed
imgusguo wants to merge 2 commits into
openrewrite:mainfrom
imgusguo:fix/8775-override-managed-plugin-version
Closed

imgusguo wants to merge 2 commits into
openrewrite:mainfrom
imgusguo:fix/8775-override-managed-plugin-version

Conversation

@imgusguo

@imgusguo imgusguo commented Sep 5, 2026 •

Copy link
Copy Markdown

What's changed?

  • Add opt-in overrideManagedVersion to UpgradePluginVersion, used with addVersionIfMissing: true to override versions inherited from an external parent.
  • Compare against the effective managed version, preserving property resolution and avoiding downgrades. Keep local/reactor-managed versions upgraded in place without redundant child versions.
  • Scope each edit to the plugin tag that was checked, so another declaration in a profile cannot be downgraded.
  • Preserve the six-argument constructor and existing defaults; add positive/negative regression tests and update the generated recipe options catalog.

What's your motivation?

Fixes #8775.

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

The new option deliberately leaves the existing trustParent placeholder unchanged. Both overrideManagedVersion and addVersionIfMissing must be enabled to add an external-parent override.

Validation

  • Updated the existing branch with upstream main at bba4454a in 0da87fd. Resolved the NullSource import and generated catalog conflicts, preserving upstream's parent-recipe catalog entry and recent composite-version/property-reference fixes.
  • Supplemental JDK 21 validation of the merged branch's complete UpgradePluginVersionTest class: 38 tests, 34 passed, 4 existing skips, 0 failures/errors. The merged recipe, test class, and repository's OkHttpSender test helper were compiled unchanged in an isolated validation project.
  • Supplemental dependencies are public OpenRewrite 8.90.4, the latest artifacts available on Maven Central. This is not a full current-main Gradle build and does not validate every change in newer dependency implementations.
  • The standard ./gradlew :rewrite-maven:test --tests 'org.openrewrite.maven.UpgradePluginVersionTest*' could not start locally because the Gradle 9.8.2 distribution download timed out. No project build configuration or dependencies were changed to work around it.
  • Ran MavenRecipeMarketplaceGenerator against the patched recipe and verified all seven generated option descriptors match the committed catalog, retaining the current upstream CSV schema and category hierarchy.
  • git diff --check passes. The PR remains limited to the original three files.

The current cgp check is waiting for approval: an upstream maintainer with write access needs to click Build on CGP for the updated head commit. The full repository build is still awaiting that validation.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've run ./gradlew build locally, and committed any resulting changes to recipes.csv
  • I've formatted the lines I changed, without reformatting code I didn't touch

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Sep 5, 2026
@imgusguo
imgusguo marked this pull request as ready for review September 26, 2026 07:40
@imgusguo

Copy link
Copy Markdown
Author

The PR is ready for review. Local current-main Gradle testing is blocked by unavailable CodeGenome credentials; the supplemental JDK 21 results are documented above. No CI checks are currently attached to the head commit. Could a maintainer help check or enable repository CI and review the opt-in external-parent override behavior? I'm happy to address feedback.

imgusguo commented Oct 7, 2026

Copy link
Copy Markdown
Author

The CI run expired while waiting for approval, without executing any build or test jobs: https://github.com/openrewrite/rewrite/actions/runs/33948051351
Could a maintainer please approve and retrigger CI for this PR? Thank you!

@timtebeek

Copy link
Copy Markdown
Member

Thanks for working on this, @imgusguo! #9593 has since landed a fix for the same problem: an explicit plugin version now overrides one managed by an inherited parent, using the existing trustParent: false and addVersionIfMissing: true options and without a new option. Closing this as superseded by #9593. If a case still isn't handled on the latest snapshot, please open an issue or a follow-up PR.

@timtebeek timtebeek closed this Nov 3, 2026
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

UpgradePluginVersion cannot raise a plugin whose version is managed by a parent outside the repository

2 participants