Skip to content

Backport #12633: Emit clear error when running JDK cannot compile source level - #12922

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12633-to-4.0.x
Aug 29, 2026
Merged

Backport #12633: Emit clear error when running JDK cannot compile source level#12922
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12633-to-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Backport of #12633 to maven-4.0.x.

  • Core: When the running JDK's javac no longer supports the project's --source/--release level (per JEP 182 retirement schedule), emit a clear, actionable error telling the user which JDK version they need and how to fix it (run mvnup)
  • mvnup: ToolchainPluginStrategy detects old source levels and adds maven-toolchains-plugin with select-jdk-toolchain goal and version constraint (e.g. <version>(,8]</version>)
  • IT: Integration test using mvn --up (leveraging MNG-2520 delegation)

Test plan

  • Unit tests: JdkSourceLevelSupportTest (19 tests), DefaultToolchainManagerTest (17 tests), ToolchainPluginStrategyTest (20 tests)
  • Integration test: MavenITMvnupToolchainPluginStrategyTest
  • CI green on maven-4.0.x

🤖 Generated with Claude Code

@gnodet gnodet added this to the 4.0.0-rc-7 milestone Aug 29, 2026
@gnodet gnodet added enhancement New feature or request backport mvn4 labels Aug 29, 2026
@gnodet
gnodet force-pushed the backport/12633-to-4.0.x branch from e1e9cdb to bdc04aa Compare August 29, 2026 19:21
…'s source level

Backport of PR #12633 from master to maven-4.0.x.

When a project's required --source/--release level is not supported by
the running JDK (per JEP 182 retirement schedule), Maven now emits a
clear, actionable error message instead of letting the build fail later
with a cryptic javac error. The error tells the user which JDK version
they need and how to fix it (run mvnup to add the
maven-toolchains-plugin with automatic JDK discovery).

Includes:
- JdkSourceLevelSupport utility mapping JDK versions to supported source levels
- Compatibility check in DefaultToolchainManager for JDK source level
- mvnup ToolchainPluginStrategy: auto-add maven-toolchains-plugin
- Integration tests for both the toolchain manager and mvnup strategy

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet
gnodet force-pushed the backport/12633-to-4.0.x branch from bdc04aa to 55d10fe Compare August 29, 2026 20:26

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean backport of #12633 ("Emit clear error when running JDK cannot compile source level") to maven-4.0.x. No issues found.

Backport observations:

  • All differences from the original are appropriate branch adaptations:
    • IT test uses File instead of Path (4.0.x extractResources() returns File, not Path as on master)
    • @since changed from 4.1.0 to 4.0.0-rc-7
    • IT test class is public with ALL_MAVEN_VERSIONS constructor matching 4.0.x conventions
    • The chmod hunk for maven.multiModuleProjectDirectory is absent (that section doesn't exist in the 4.0.x pom.xml)
  • No changes were dropped or modified beyond these framework adaptations.
  • All API dependencies verified on maven-4.0.x: UpgradeOptions, AbstractUpgradeStrategy, UpgradeResult, DomUtils, TestUtils, Source.getTargetVersion(), Build.getSources() all exist on the target branch.
  • Test coverage is comprehensive: 19 tests for JdkSourceLevelSupport, 17 for DefaultToolchainManager, 20 for ToolchainPluginStrategy, plus an integration test.
  • Backporting to 3.9.x / 3.10.x is not applicable (Maven 4.x-only APIs: mvnup, UpgradeStrategy, Model 4.1.0 Source elements).

This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.

Claude Code on behalf of Guillaume Nodet

@gnodet
gnodet merged commit b09982a into maven-4.0.x Aug 29, 2026
42 of 43 checks passed
@gnodet
gnodet deleted the backport/12633-to-4.0.x branch August 29, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport enhancement New feature or request mvn4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant