gnodet opened a new pull request, #13366: URL: https://github.com/apache/maven/pull/13366
## Summary Make `org.apache.maven.api.MojoExecution` `@Immutable` and introduce noun-based accessors consistent with the rest of the Maven 4.1 API. ## Root Cause `MojoExecution` exposed getter-prefixed methods (`getPlugin()`, `getGoal()`, etc.) and its implementation (`DefaultMojoExecution`) held a live reference to the mutable legacy `org.apache.maven.plugin.MojoExecution`. The delegate is mutated extensively during build plan calculation (configuration merging, descriptor resolution, phase assignment), making the annotation incorrect and the contract unclear. ## Fix ### 1. Noun-based accessors on the interface The `get`-prefixed abstract methods are replaced by noun-based equivalents following the pattern established by `ExecutionEvent`, `Node`, etc.: | Old (deprecated) | New | |---|---| | `getPlugin()` | `plugin()` | | `getModel()` | `model()` | | `getDescriptor()` | `descriptor()` | | `getExecutionId()` | `executionId()` | | `getGoal()` | `goal()` | | `getLifecyclePhase()` | `lifecyclePhase()` | | `getConfiguration()` | `configuration()` | The old names are kept as `@Deprecated(since = "4.1.0", forRemoval = true)` default methods delegating to the new ones, preserving binary and source compatibility for existing plugin code. ### 2. True immutable snapshot in `DefaultMojoExecution` The implementation no longer holds a reference to the mutable legacy `MojoExecution`. All fields are captured at construction time — which always occurs after plan calculation is complete (in `DefaultBuildPluginManager.executeMojo()` and `DefaultMavenPluginManager.loadV4Mojo()`), so the snapshot correctly reflects the final, fully-configured state. The `getDelegate()` escape hatch is removed: there is nothing left to delegate to. `@Immutable` is now honest. ## Tests Existing `PluginParameterExpressionEvaluatorV4Test` (20 tests) passes without modification — the deprecated default methods provide backward compatibility. _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]
