Repository navigation
Open
Labels
enhancementNew feature or request
Description
Summary
The Maven v4 API has ExecutionListener and RepositoryListener in maven-api-core, both extending Listener, with corresponding event types extending Event. There is currently no equivalent for project-level lifecycle callbacks (before/after project execution, with access to the execution plan and failure information).
Proposed additions in maven-api-core
ProjectExecutionEvent extends Event
@Experimental
@Immutable
public interface ProjectExecutionEvent extends Event {
/** The project whose lifecycle is being executed. */
@Nonnull Project project();
/** Immutable snapshot of the project's execution plan (list of MojoExecution). */
@Nonnull List<MojoExecution> executionPlan();
/** The failure that ended project execution, or empty when successful or not yet started. */
@Nonnull Optional<Throwable> failure();
}ProjectExecutionListener extends Listener
@Experimental
@Consumer
@ThreadSafe
public interface ProjectExecutionListener extends Listener {
default void beforeProjectExecution(@Nonnull ProjectExecutionEvent event) {}
default void afterProjectExecution(@Nonnull ProjectExecutionEvent event) {}
}Relationship to existing types
- Complements
ExecutionListener(which covers session-level and mojo-level events) with project-level granularity including access to the full execution plan. afterSessionEndcoverage is already handled byExecutionListener.sessionEnded().- Dispatch follows the existing
EventSpyImplpattern: exceptions are caught, logged as WARN, and swallowed — listeners are observers and cannot abort the build.
Auto-discovery
Implementations should be auto-discoverable as core extensions without requiring manual Session.registerListener() calls. See #13805 for the general SpiService + Listener auto-discovery mechanism.
Related
- v4 SPI: Lifecycle participation (afterProjectsRead, per-project callbacks, session end) #13514 — lifecycle participation SPI (afterProjectsRead)
- Allow Listener implementations to be auto-discovered as SPI services #13805 — Listener auto-discovery as SpiService
- [MNG-7510] Enhance AbstractMavenLifecycleParticipant to watch for buildProject events #9285 — original request for per-project lifecycle callbacks
- Migrate lifecycle engine to v4 API #13464 — lifecycle engine migration to v4 API
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
refactor: narrow LifecycleParticipant scope to afterProjectsRead only
feat: introduce ProjectTransformer SPI for functional model transform…