Class AetherBasedResolver

  • All Implemented Interfaces:
    Closeable, AutoCloseable, MavenResolver

    public class AetherBasedResolver
    extends Object
    implements MavenResolver

    MavenResolver based on Apache Maven Resolver (formerly - Eclipse Aether Resolver (formerly - Sonatype Aether Resolver)).

    The resolution process is almost the same as in usual mvn invocation with one big difference. While in pure Maven, remote repositories are used to download the artifacts to local repository if not already available, in Pax URL Aether, there's an initial resolution attempt based on default repositories which are treated as local repositories without write access. This is important for managing separate directories with Maven-like structure - for example in $KARAF_HOME/system.

    • Constructor Detail

      • AetherBasedResolver

        public AetherBasedResolver​(MavenConfiguration configuration)
        Create a AetherBasedResolver
        Parameters:
        configuration - (must be not null)
      • AetherBasedResolver

        public AetherBasedResolver​(MavenConfiguration configuration,
                                   MirrorInfo mirror)
        Create a AetherBasedResolver
        Parameters:
        configuration - (must be not null)
        mirror -
    • Method Detail

      • resolve

        public File resolve​(org.eclipse.aether.artifact.Artifact artifact,
                            MavenRepositoryURL url,
                            Exception previousException)
                     throws IOException
        Main resolution method that resolves artifact using data from Artifact and repositories prepared from global configuration.
        Parameters:
        artifact -
        url - extra URL for remote repository to check if the original mvn: URI included source repository
        previousException -
        Returns:
        Throws:
        IOException
      • resolve

        public File resolve​(List<AetherBasedResolver.LocalRepositoryWithConfig> defaultRepositories,
                            List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories,
                            org.eclipse.aether.artifact.Artifact artifact)
                     throws IOException

        Main resolution method that operates on passed default and remote repositories and doesn't determine the checked repositories on its own.

        This is the main method that implements Pax URL resolution, which involves a set of default repositories and defaults to remote repository resolution if artifact is not found.

        This method requires that RemoteRepository objects used are already processed (mirrors, proxies, auth).

        Parameters:
        defaultRepositories -
        remoteRepositories -
        artifact -
        Returns:
        Throws:
        IOException
      • findAetherException

        protected org.eclipse.aether.RepositoryException findAetherException​(Exception e)
        Find top-most Aether exception
        Parameters:
        e -
        Returns:
      • rootException

        protected Throwable rootException​(Exception ex)
        Find root exception
        Parameters:
        ex -
        Returns:
      • assignMirrorsAndProxies

        public List<org.eclipse.aether.repository.RemoteRepository> assignMirrorsAndProxies​(org.eclipse.aether.RepositorySystemSession session,
                                                                                            List<org.eclipse.aether.repository.RemoteRepository> repositories)

        Pax URL 2.6 manually checked mirros, proxies and authentication configuration to replace list of target repositories with mirrored/proxied ones.

        Here we'll use RepositorySystem.newResolutionRepositories(org.eclipse.aether.RepositorySystemSession, java.util.List<org.eclipse.aether.repository.RemoteRepository>). If passes session is null, a static session is used that satisfies requirements of underlying resolver mechanisms (like getting global update/checksum policies).

        Parameters:
        session -
        repositories -
        Returns: