Skip to content

[MNG-8547] The API is missing a way to listen to repository events #10677

Closed

Description

@jira-importer

Guillaume Nodet opened MNG-8547 and commented

The Session#registerListener() should provide a specific interface to listen to resolver events (wrapping somehow the resolver's org.eclipse.aether.RepositoryListener interface.


Implemented in #13011

The Maven API now exposes both repository and execution events through Maven-owned types, without leaking Resolver types into the public API.

New API types (maven-api-core)

Repository events:

  • RepositoryListener — @Consumer interface with 19 default methods, one per RepositoryEventType (artifact/metadata resolve, download, install, deploy, and descriptor events)
  • RepositoryEvent — immutable event object carrying artifact, metadata, repository, path, exception(s), and request trace
  • RepositoryEventType — enum of 19 event kinds

Execution events:

  • ExecutionListener — @Consumer interface with 17 default methods, one per ExecutionEventType
  • ExecutionEvent — immutable event object with noun-style accessors (project(), mojoExecution(), exception(), type())
  • ExecutionEventType — enum of 17 event kinds

Shared base:

  • Event — base interface with session() accessor; deprecated bridge methods (getType(), getSession(), getProject(), getMojoExecution(), getException()) preserved for backward compatibility
  • RepositoryMetadata — immutable Maven API wrapper for repository metadata with noun-style accessors (type(), nature(), groupId(), artifactId(), version(), filename())
  • Listener remains @FunctionalInterface; existing lambdas continue to receive execution events unchanged

Listener registration

Session.registerListener(Listener) / unregisterListener(Listener) / getListeners() accept any Listener instance. Typed listeners (ExecutionListener, RepositoryListener) receive only their event-family callbacks. A single listener can implement both. Registration is thread-safe (CopyOnWriteArrayList) and shared across Maven sessions backed by the same Resolver session. Listener failures are isolated and do not break the build.

Implementation (maven-impl, maven-core)

  • DefaultRepositoryEvent — maps Resolver RepositoryEvent to the Maven API type
  • MavenRepositoryListener — bridges Resolver events to registered RepositoryListener instances
  • DefaultRepositorySystemSessionFactory — wires the bridge into the session
  • AbstractSession, DefaultEvent, EventSpyImpl, ApiRunner — updated for the unified hierarchy

Activity

  1. added
    enhancement
    priority:major
    on Jul 7, 2025
  2. goutamadwant commented on Sep 2, 2026

    @goutamadwant
    Contributor

    @gnodet added this enhancement in #13011 using Maven-owned repository event and listener types.let me know if you have any comments or suggestions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:major

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions