Skip to content

[Backport maven-4.0.x] Fix #12989: mvnup plugin upgrades should respect project JDK version - #13024

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport/fix-12989-to-4.0.x
Sep 2, 2026
Merged

gnodet merged 1 commit into
maven-4.0.xfrom
backport/fix-12989-to-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Backport of #12994 to maven-4.0.x.

Cherry-pick of 5caa2a0 from master.

Summary

Adds JDK compatibility checking to PluginUpgradeStrategy so that plugin upgrades requiring a higher JDK than the project targets are skipped rather than blindly applied. Prevents UnsupportedClassVersionError (e.g., checkstyle-plugin 3.6.0 → Checkstyle 10.x requires JDK 21).

Changes

  • Adds minJdk field to PluginUpgrade record (defaults to 0 = no restriction)
  • Detects project JDK from maven.compiler.release, .source, .target, and compiler plugin config
  • Guards both direct and effective-model upgrade paths
  • Registers maven-checkstyle-plugin 3.6.0 with minJdk=21
  • 20 new tests for JDK detection and compatibility skip logic

* Fix #12989: mvnup plugin upgrades should respect project JDK version

Add JDK compatibility checking to PluginUpgradeStrategy so that plugins
requiring a higher JDK than the project targets are skipped rather than
blindly upgraded. This prevents UnsupportedClassVersionError at build
time (e.g., checkstyle-plugin 3.6.0 pulls Checkstyle 10.x which
requires JDK 21, breaking projects that target JDK 17).

Changes:
- Add minJdk field to PluginUpgrade record and PluginUpgradeInfo class
- Add detectProjectJdkVersion() method that reads maven.compiler.release,
  maven.compiler.source, maven.compiler.target, and compiler plugin config
- Add JDK compatibility guard in upgradePluginVersion() (similar to the
  existing Quarkus 2.x skip pattern)
- Add JDK compatibility guard in effective model analysis path
- Register maven-checkstyle-plugin 3.6.0 with minJdk=21
- Add comprehensive tests in PluginUpgradeJdkCompatibilityTest

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Address review feedback: extract JDK skip helper, sort POMs by path depth

- Extract duplicated JDK compatibility check into shouldSkipForJdkIncompatibility()
  helper method, eliminating the inline logic in both build/plugins and
  pluginManagement/plugins analysis paths
- Sort pomMap entries by path depth (shortest first) when detecting the project
  JDK version, so the root POM is checked before child modules in multi-module
  projects

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 2, 2026
@gnodet gnodet added the bug Something isn't working label Sep 2, 2026
@gnodet gnodet self-assigned this Sep 2, 2026
@gnodet
gnodet merged commit fde2f59 into maven-4.0.x Sep 2, 2026
24 checks passed
@gnodet
gnodet deleted the backport/fix-12989-to-4.0.x branch September 2, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant