Backport #12633: Emit clear error when running JDK cannot compile source level - #12922
Merged
Conversation
gnodet
force-pushed
the
backport/12633-to-4.0.x
branch
from
August 29, 2026 19:21
e1e9cdb to
bdc04aa
Compare
…'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
force-pushed
the
backport/12633-to-4.0.x
branch
from
August 29, 2026 20:26
bdc04aa to
55d10fe
Compare
gnodet
commented
Aug 29, 2026
gnodet
left a comment
Contributor
Author
There was a problem hiding this comment.
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
Fileinstead ofPath(4.0.xextractResources()returnsFile, notPathas on master) @sincechanged from4.1.0to4.0.0-rc-7- IT test class is
publicwithALL_MAVEN_VERSIONSconstructor matching 4.0.x conventions - The
chmodhunk formaven.multiModuleProjectDirectoryis absent (that section doesn't exist in the 4.0.x pom.xml)
- IT test uses
- 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 forDefaultToolchainManager, 20 forToolchainPluginStrategy, 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
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.
Summary
Backport of #12633 to
maven-4.0.x.javacno longer supports the project's--source/--releaselevel (per JEP 182 retirement schedule), emit a clear, actionable error telling the user which JDK version they need and how to fix it (runmvnup)ToolchainPluginStrategydetects old source levels and addsmaven-toolchains-pluginwithselect-jdk-toolchaingoal and version constraint (e.g.<version>(,8]</version>)mvn --up(leveraging MNG-2520 delegation)Test plan
JdkSourceLevelSupportTest(19 tests),DefaultToolchainManagerTest(17 tests),ToolchainPluginStrategyTest(20 tests)MavenITMvnupToolchainPluginStrategyTestmaven-4.0.x🤖 Generated with Claude Code