Interface RepositoryAwareRequest

All Superinterfaces:
Request<Session>
All Known Subinterfaces:
ArtifactResolverRequest, DependencyResolverRequest, ModelBuilderRequest, ProjectBuilderRequest, VersionRangeResolverRequest, VersionResolverRequest

@Experimental @Immutable public interface RepositoryAwareRequest extends Request<Session>
Base interface for service requests that involve remote repository operations. This interface provides common functionality for requests that need to specify and validate remote repositories for artifact resolution, dependency collection, model building, and other Maven operations.

Implementations of this interface can specify a list of remote repositories to be used during the operation. If no repositories are specified (null), the session's default remote repositories will be used. The repositories are validated to ensure they don't contain duplicates or null entries.

Remote repositories are used for:

  • Resolving artifacts and their metadata
  • Downloading parent POMs and dependency POMs
  • Retrieving version information and ranges
  • Accessing plugin artifacts and their dependencies

Repository validation ensures data integrity by:

  • Preventing duplicate repositories that could cause confusion
  • Rejecting null repository entries that would cause failures
  • Maintaining consistent repository ordering for reproducible builds
Since:
4.0.0
See Also:
  • Method Details

    • getRepositories

      @Nullable List<RemoteRepository> getRepositories()
      Returns the list of remote repositories to be used for this request.

      If this method returns null, the session's default remote repositories will be used. If a non-null list is returned, it will be used instead of the session's repositories, allowing for request-specific repository configuration.

      The returned list should not contain duplicate repositories (based on their equality) or null entries, as these will cause validation failures when the request is processed.

      Returns:
      the list of remote repositories to use, or null to use session defaults
      See Also:
    • validate

      default List<RemoteRepository> validate(List<RemoteRepository> repositories)
      Validates a list of remote repositories to ensure data integrity.

      This method performs the following validations:

      • Allows null input (returns null)
      • Ensures no duplicate repositories exist in the list
      • Ensures no null repository entries exist in the list

      Duplicate detection is based on the RemoteRepository#equals(Object) method, which typically compares repository IDs and URLs.

      Parameters:
      repositories - the list of repositories to validate, may be null
      Returns:
      the same list if validation passes, or null if input was null
      Throws:
      IllegalArgumentException - if the list contains duplicate repositories
      IllegalArgumentException - if the list contains null repository entries