Skip to content

Fix #12983: ToolchainPluginStrategy handles inherited source levels - #12992

Closed
gnodet wants to merge 1 commit into
masterfrom
fix/12983-toolchain-inherited-source-levels
Closed

Fix #12983: ToolchainPluginStrategy handles inherited source levels#12992
gnodet wants to merge 1 commit into
masterfrom
fix/12983-toolchain-inherited-source-levels

Conversation

@gnodet

@gnodet gnodet commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds effective model resolution as a fallback when ToolchainPluginStrategy finds no source level in the local POM DOM
  • When maven.compiler.source/target is inherited from a parent POM (e.g., geronimo-genesis sets source=1.5), mvnup now resolves the effective source level via buildEffectiveModel() and configures the auto-toolchain for JDK 8/11 compilation
  • This fixes the 12 Apache projects (ftpserver, geronimo-genesis, aries-tx-control, etc.) that fail with "Source option N is no longer supported" under Maven 4

Design

The fix follows the same pattern used by CompatibilityFixStrategy.collectEffectiveProperties():

  1. Fast path (unchanged): inspect the local POM DOM for maven.compiler.release, maven.compiler.source, or compiler plugin config
  2. Fallback path (new): if the fast path returns -1, build the effective Maven model which resolves all inherited properties from parent POMs, then check maven.compiler.release and maven.compiler.source from the effective properties
  3. Failures in effective model resolution are caught and logged at debug level — the strategy degrades gracefully

Test plan

  • Unit tests for detectSourceLevelFromEffectiveModel() (6 tests): release property, source property, precedence, legacy 1.x format, empty properties, no compiler properties
  • Integration-style tests for doApply() with inherited source levels (5 tests): plugin added for inherited incompatible source, no modification for compatible inherited source, graceful fallback on resolution failure, local takes precedence over effective, correct JDK constraint (source 6 → JDK 11)
  • All 31 tests pass, format check passes

🤖 Generated with Claude Code

…rom parent POMs

When maven.compiler.source/target is inherited from a parent POM (e.g.,
geronimo-genesis sets source=1.5), mvnup now resolves the effective source
level using Maven's model builder and configures the auto-toolchain for
JDK 8/11 compilation. Previously it only inspected the local POM.

The fix adds a fallback path in doApply: when the fast DOM-based detection
finds no source level in the local POM, it builds the effective model to
resolve inherited properties. This handles the 12 Apache projects that
fail with "Source option N is no longer supported" under Maven 4.

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

gnodet commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #12973, which fixes the same issue (inherited source level detection in ToolchainPluginStrategy) and also includes session caching improvements via MvnupSessionHolder and RequestCache deduplication.

@gnodet gnodet closed this Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant