gnodet opened a new issue, #13762:
URL: https://github.com/apache/maven/issues/13762
## Summary
Maven 4 introduced `before:`/`after:` phase prefixes, `all`/`each`
reactor-scoped phases, `@After` constraints, and `@Resolution` per-field
injection as replacements for the `aggregator=true` flag and `@Execute`
annotation. However, neither `aggregator` nor `@Execute` has been marked as
deprecated, and no runtime warnings guide plugin authors toward the new API.
## Problem
Plugin authors have no indication that `aggregator=true` and `@Execute` are
superseded. The `@Mojo(aggregator = true)` attribute and `@Execute` annotation
in `api/maven-api-core` carry no `@Deprecated` marker. When Maven loads a
plugin descriptor containing `<aggregator>true</aggregator>` or
`<executePhase>`, no warning is logged. Plugin authors will continue using the
legacy API indefinitely without a signal to migrate.
## Proposed Changes
### 1. Mark annotations as deprecated
- Add `@Deprecated` to `@Mojo.aggregator()` in
`api/maven-api-core/.../annotations/Mojo.java`
- Add `@Deprecated` to `@Execute` annotation in
`api/maven-api-core/.../annotations/Execute.java`
- Add Javadoc `@deprecated` tags pointing to the replacements
(`after:all`/`before:all` phases, `@After`, `@Resolution`)
### 2. Emit runtime warnings when deprecated features are used
When Maven loads a plugin descriptor containing these features, log a
warning such as:
```
[WARNING] Plugin 'groupId:artifactId:version' uses deprecated
'aggregator=true'.
Use 'after:all' or 'after:<phase>' phase binding instead.
See
https://maven.apache.org/guides/plugin/aggregator-migration.html
```
**Insertion points in the codebase:**
- `PluginDescriptorBuilder` — where `<aggregator>true</aggregator>` is parsed
- `PluginDescriptorBuilder` — where `<executePhase>`, `<executeGoal>`,
`<executeLifecycle>` are parsed
The warning should be emitted once per plugin (not per mojo execution) to
avoid log spam.
### 3. What each deprecated feature maps to
| Deprecated | Replacement | Available since |
|---|---|---|
| `@Mojo(aggregator = true)` execution scope | `after:all` / `after:<phase>`
phase binding | Maven 4.x |
| `@Mojo(aggregator = true)` resolution scope | `@Resolution` per-field
injection | Maven 4.x |
| `@Execute(phase = ...)` lifecycle forking | `@After` constraint annotation
| Maven 4.x |
| `aggregatorLock` (implicit in `-T` builder) | DAG edges (concurrent
builder) | Maven 4.x |
## Context
- `@After` exists at `api/maven-api-core/.../annotations/After.java` (marked
`@Experimental`)
- `@Resolution` exists at
`api/maven-api-core/.../annotations/Resolution.java` (marked `@Experimental`)
- `before:`/`after:` phases work with **all** builders (not just the
concurrent builder), as demonstrated by `MavenITmng8244PhaseAllTest` which
tests both legacy and concurrent builders
- Related: #8718 (aggregator goals umbrella), PR #13330 (architecture
documentation)
_Claude Code 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]