gnodet opened a new pull request, #14168:
URL: https://github.com/apache/maven/pull/14168
## Summary
`ToolchainPluginStrategy` now computes the reactor-wide minimum source level
before
deciding 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) and
a child module declares `source=5` (retired — no longer accepted by JDK ≥
9), the
root POM was always skipped because `latestJdkForSourceLevel(8) == -1`. The
child
would 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`, and
`tomee-release-tools`, all of which have root `source=8` with one or more
child
modules using `source=4` or `source=5`.
## Fix
The single-pass loop is replaced with a three-pass approach:
1. **Pass 1 — collection**: gather `{pomPath → detectedSourceLevel}` for
every POM
in the reactor (using the existing local-first + effective-model-fallback
detection).
2. **Pass 2 — reactor minimum**: compute the minimum source level across all
entries.
3. **Pass 3 — injection**: for each POM that declares a source level,
determine the
effective JDK bound as `min(ownLevel, reactorMin)`:
- A POM whose own level is **not retired** but whose reactor minimum **is
retired**
now also receives the toolchain (fixes the root-POM gap).
- A POM whose own level **is retired** still uses the stricter reactor
minimum
when available.
- POMs with **no declared source level** are still skipped.
## Tests
Three new unit tests cover:
| Test | Scenario |
|---|---|
| `addsToolchainToRootWhenChildHasRetiredLevel` | Root `source=8`, child
`source=5` → both modified with `(,8]` |
| `noToolchainWhenOnlyRootHasNonRetiredLevel` | Root `source=8`, child no
source → neither modified |
| `usesReactorMinimumWhenRootHasHigherRetiredLevel` | Root `source=7`, child
`source=5` → both use `(,8]` (child's stricter bound) |
Fixes #14166
---
_Hermes Agent (Claude Sonnet 4.5) on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]