goutamadwant opened a new pull request, #13041:
URL: https://github.com/apache/maven/pull/13041
Fixes #6918.
## Problem
When lifecycle bindings introduce a plugin that also appears in
`pluginManagement`, Maven currently clones and merges the entire managed
plugin. This makes `pluginManagement` active by copying managed executions into
the lifecycle plugin, even though the plugin was never declared in
`build/plugins`.
On current `master`, a `maven-clean-plugin` execution named `custom-clean`,
declared only in `pluginManagement` and bound to `initialize`, is executed by
`mvn initialize`.
## Change
- Use the lifecycle-supplied plugin as the merge base.
- Overlay only the managed plugin version and configuration, preserving
their existing dominance.
- Keep lifecycle executions and all other plugin-level fields unchanged.
- Apply the same behavior to the legacy mutable model and the Maven 4
immutable model.
This preserves the existing behavior where lifecycle plugins obtain their
version and configuration from `pluginManagement`, while keeping managed
executions passive until the plugin is explicitly declared.
## Tests
- Added focused merger tests for both model implementations. They verify:
- managed version and configuration are applied;
- managed configuration wins on conflicting keys;
- lifecycle executions and input locations are preserved;
- managed executions, dependencies, extensions, and inheritance flags are
not copied.
- Added `MavenITmng5359PluginManagementExecutionTest` with two end-to-end
paths:
- a management-only execution remains inactive;
- the same execution activates when the plugin is explicitly declared.
- Ran `mvn -Prun-its -Dits.test=MavenITmng5359PluginManagementExecutionTest
verify` successfully across all 90 reactor modules.
- Verified the built CLI directly: management-only `initialize` executes no
clean goal, explicit-plugin `initialize` executes `custom-clean`, and the
normal `clean` lifecycle still executes only `default-clean`.
## Compatibility and scope
This change is limited to lifecycle-binding injection and does not modify
public APIs. Explicit `build/plugins` declarations continue to receive normal
plugin-management merging. The implementation replaces the previous
clone/full-merge path with one clone or builder plus two field merges.
Following this checklist to help us incorporate the contribution quickly and
easily:
- [x] This pull request addresses one issue without unrelated changes.
- [x] The description explains what the pull request does, how, and why.
- [x] The commit has a meaningful subject line and body.
- [x] Behavioral unit tests fail without the runtime change.
- [x] `mvn verify` passed as part of the broader `mvn -Prun-its verify` run.
- [x] The targeted Core IT passed successfully.
- [ ] I hereby declare this contribution to be licenced under the [Apache
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, I have filed an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
--
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]