gnodet opened a new pull request, #13058: URL: https://github.com/apache/maven/pull/13058
## Description Introduce a base `Event`/`Listener` hierarchy to support multiple event families (execution, repository, etc.) through a single registration point on `Session`. This PR refactors the existing `Event`/`Listener`/`EventType` types and introduces new typed specializations for build lifecycle events. The design enables PR #13011 to integrate its `RepositoryEvent`/`RepositoryListener` into the same hierarchy by simply extending `Event` and `Listener`. ### API changes | Type | Change | |------|--------| | `Event` | Stripped to base marker: `@Immutable`, single `session()` noun-style accessor | | `ExecutionEvent` | **New** — typed execution event (`extends Event`) with `type()`, `project()`, `mojoExecution()`, `exception()` | | `ExecutionEventType` | **New** — renamed from `EventType` for clarity, same values in same order | | `EventType` | `@Deprecated(forRemoval)` — alias with bridge methods to `ExecutionEventType` | | `ExecutionListener` | **New** — typed callbacks (`extends Listener`) with per-event-type `default` methods | | `Listener` | Refactored to base marker, `@FunctionalInterface` removed, `onEvent()` deprecated as `default` | ### Impl changes - `DefaultEvent`: implements `ExecutionEvent` with noun-style accessors - `EventSpyImpl`: dispatches to both legacy `Listener.onEvent()` and typed `ExecutionListener` callbacks ### Design ``` Event (@Immutable, base marker) ├── ExecutionEvent (project, mojo, session lifecycle) └── RepositoryEvent (artifact/metadata — PR #13011) Listener (@Consumer, base marker) ├── ExecutionListener (typed default callbacks) └── RepositoryListener (typed default callbacks — PR #13011) ``` Key properties: - **Single registration**: `Session.registerListener(Listener)` handles all listener types — no method overloading - **Extensible**: future event categories just add `XxxEvent extends Event` + `XxxListener extends Listener` - **Backward compatible**: old `Listener.onEvent()` stays as `@Deprecated default` - **Noun-style accessors** on new types, consistent with #13036 - `Session.java`, `AbstractSession.java`, `SessionStub.java` are **unchanged** — the existing `List<Listener>` works for both old and new listener types ### Relationship with PR #13011 This PR provides the hierarchy foundation. PR #13011 should merge this, then: 1. Make `RepositoryEvent extends Event` (add `session()` accessor) 2. Make `RepositoryListener extends Listener` 3. Remove the separate `registerListener(RepositoryListener)`/`getRepositoryListeners()` methods from `Session` 4. Use noun-style accessors on `RepositoryEvent` and `RepositoryMetadata` --- - [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 and body. - [x] `mvn verify` passes. - [x] 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) -- 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]
