Repository navigation
Conversation
added 2 commits
November 28, 2026 13:56
…ce level (apache#14166) ToolchainPluginStrategy was processing each POM independently and using that POM's own declared source level to decide whether to inject the maven-toolchains-plugin. When the root POM declared source=8 (not retired), it was always skipped — even when a child module in the same reactor declared a retired source level (e.g. source=5, retired since JDK 9) that requires a toolchain. Fix: replace the single-pass per-POM loop with a two-pass approach: Pass 1 — collect the source level from every POM in the reactor (using the same local-first + effective-model-fallback detection already in place). Pass 2 — compute the reactor-wide minimum source level. Pass 3 — apply toolchain plugin to each POM that declares a source level, using the most restrictive (lowest) bound from the reactor: - A POM whose own level is not retired but whose reactor minimum is retired now receives the toolchain (fixes the root-POM case). - A POM whose own level is already retired uses the reactor minimum when it is even more restrictive. - POMs that declare no source level at all are still skipped. Fixes apache#14166
The IT test MavenITgh12922MvnupToolchainPluginStrategyTest verifies the log contains 'Added maven-toolchains-plugin with select-jdk-toolchain goal', which is the upstream message. My previous commit mistakenly changed the message to 'maven-toolchains-plugin addition', breaking the IT on all 9 OS/JDK matrix combinations.
gnodet
marked this pull request as ready for review
November 28, 2026 17:56
gnodet-bot
approved these changes
Nov 29, 2026
gnodet-bot
left a comment
Contributor
There was a problem hiding this comment.
Correct reactor-wide minimum source level computation. The 3-pass approach (collect → compute min → apply) is clean, all edge cases are handled (mixed retired/non-retired, only non-retired, both retired at different levels), and the test coverage hits the important scenarios. LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
| Document childDoc = Document.of(childPomXml); | ||
| UpgradeContext context = TestUtils.createMockContext(); | ||
|
|
||
| Map<Path, Document> pomMap = new java.util.LinkedHashMap<>(); |
Contributor
There was a problem hiding this comment.
🔹 Nit: FQCN instead of import — java.util.LinkedHashMap is used as a fully-qualified name in three test methods instead of an import. Minor style inconsistency; the production code properly imports its types. Same pattern at lines ~718 and ~763.
Suggested change
| Map<Path, Document> pomMap = new java.util.LinkedHashMap<>(); | |
| Map<Path, Document> pomMap = new LinkedHashMap<>(); |
(with import java.util.LinkedHashMap; in the imports section)
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
ToolchainPluginStrategynow computes the reactor-wide minimum source level beforedeciding whether (and where) to inject
maven-toolchains-plugin.Root Cause
The strategy was processing each POM independently and using that POM's own declared
source level to decide whether to inject
maven-toolchains-plugin.In a multi-module project where the root POM declares
source=8(not retired) anda child module declares
source=5(retired — no longer accepted by JDK ≥ 9), theroot POM was always skipped because
latestJdkForSourceLevel(8) == -1. The childwould correctly receive the toolchain, but the root POM (the natural injection point
for toolchain configuration that applies to all modules) was left unmodified.
Real-world projects affected include
apache/incubator-samoa,portals-pluto, andtomee-release-tools, all of which have rootsource=8with one or more childmodules using
source=4orsource=5.Fix
The single-pass loop is replaced with a three-pass approach:
Pass 1 — collection: gather
{pomPath → detectedSourceLevel}for every POMin the reactor (using the existing local-first + effective-model-fallback detection).
Pass 2 — reactor minimum: compute the minimum source level across all entries.
Pass 3 — injection: for each POM that declares a source level, determine the
effective JDK bound as
min(ownLevel, reactorMin):now also receives the toolchain (fixes the root-POM gap).
when available.
Tests
Three new unit tests cover:
addsToolchainToRootWhenChildHasRetiredLevelsource=8, childsource=5→ both modified with(,8]noToolchainWhenOnlyRootHasNonRetiredLevelsource=8, child no source → neither modifiedusesReactorMinimumWhenRootHasHigherRetiredLevelsource=7, childsource=5→ both use(,8](child's stricter bound)Fixes #14166
Hermes Agent (Claude Sonnet 4.5) on behalf of Guillaume Nodet