Skip to content

[Backport 4.0.x] Fix #12985: Upgrade toolchains-plugin when adding select-jdk-toolchain execution - #13026

Merged
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12999-toolchains-plugin-version
Sep 2, 2026
Merged

[Backport 4.0.x] Fix #12985: Upgrade toolchains-plugin when adding select-jdk-toolchain execution#13026
gnodet merged 1 commit into
maven-4.0.xfrom
backport/12999-toolchains-plugin-version

Conversation

@gnodet

@gnodet gnodet commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Backport of #12999 to maven-4.0.x.

Summary

  • When ToolchainPluginStrategy adds a select-jdk-toolchain execution, it now ensures the maven-toolchains-plugin version is >= 3.2.0 (the first version containing that goal)
  • Previously, the plugin was added without a version, causing builds to fail when the project inherited an older version like 1.1 (which only has help and toolchain goals)
  • Reuses existing toolchains-plugin entries instead of creating duplicates, and upgrades versions in both build/plugins and build/pluginManagement/plugins

…n execution (#12999)

* Fix #12985: Upgrade toolchains-plugin when adding select-jdk-toolchain execution

When ToolchainPluginStrategy adds a select-jdk-toolchain execution,
it now ensures the maven-toolchains-plugin version is >= 3.2.0 (the
first version containing that goal). Previously, the plugin was added
without a version, causing builds to fail when the project inherited
an older version like 1.1 which only has 'help' and 'toolchain' goals.

Changes:
- Set plugin version to 3.2.0 when creating a new toolchains-plugin entry
- Reuse existing toolchains-plugin entry instead of creating duplicates
- Upgrade version of existing entries below 3.2.0 (in both build/plugins
  and build/pluginManagement/plugins)
- Skip property-referenced versions to avoid unintended side effects

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

* Address review feedback: warn on property versions, extract shared matching

- Log a warning when skipping property-referenced versions (e.g.
  ${toolchains.version}) so users know to verify the resolved version
  is >= 3.2.0 manually
- Extract isToolchainsPlugin() helper to deduplicate groupId/artifactId
  matching between findToolchainsPlugin() and hasSelectGoalInPluginSection()

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

* Share plugin version upgrade via PluginUpgradeStrategy

Add maven-toolchains-plugin to the PLUGIN_UPGRADES list in
PluginUpgradeStrategy (min version 3.2.0) so existing toolchains-plugin
entries are upgraded through the same mechanism as all other plugins.

ToolchainPluginStrategy no longer duplicates version comparison and
upgrade logic — it only creates new plugin entries (with version 3.2.0)
and adds select-jdk-toolchain executions. Version upgrades of existing
entries are handled by PluginUpgradeStrategy, which runs first
(priority 10 vs 15).

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 2, 2026
@gnodet gnodet added the bug Something isn't working label Sep 2, 2026
@gnodet gnodet self-assigned this Sep 2, 2026
@gnodet
gnodet merged commit 635e637 into maven-4.0.x Sep 2, 2026
24 checks passed
@gnodet
gnodet deleted the backport/12999-toolchains-plugin-version branch September 2, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant