Class CompositeMavenRepository

  • All Implemented Interfaces:
    Closeable, AutoCloseable
    Direct Known Subclasses:
    MavenResourceRepository

    public class CompositeMavenRepository
    extends Object
    implements Closeable
    Provides a composite IMavenRepo view on several MavenBackingRepository instances. The class replaces MavenRepository which lacks some required functionality. (Besides, this class has a more appropriate name.)

    The information about artifacts is provided as a maven Model. It is evaluated using the maven libraries and should therefore be consistent with the model information used in other maven repository based tools.

    • Constructor Detail

      • CompositeMavenRepository

        public CompositeMavenRepository​(File base,
                                        String repoId,
                                        List<aQute.maven.provider.MavenBackingRepository> releaseRepos,
                                        List<aQute.maven.provider.MavenBackingRepository> snapshotRepos,
                                        Executor executor,
                                        aQute.service.reporter.Reporter reporter)
                                 throws Exception
        Instantiates a new composite maven repository.
        Parameters:
        base - the base
        repoId - the repository id
        releaseRepos - the backing release repositories
        snapshotRepos - the backing snapshot repositories
        executor - an executor
        reporter - the reporter
        Throws:
        Exception - the exception
    • Method Detail

      • name

        public String name()
        Gets the name of this repository.
        Returns:
        the name
      • reset

        public void reset()
        Reset any cached information.
      • backing

        public List<aQute.maven.provider.MavenBackingRepository> backing()
        Returns all backing repositories.
        Returns:
        the list of all repositories
      • backingAsStream

        public Stream<aQute.maven.provider.MavenBackingRepository> backingAsStream()
        Returns all repositories as a stream.
        Returns:
        the repositories as stream
      • retrieve

        public Promise<Fileretrieve​(aQute.maven.api.Archive archive)
                               throws IOException
        Retrieves the file from a remote repository into the repositories local cache directory if it doesn't exist yet.
        Parameters:
        archive - The archive to fetch
        Returns:
        the file or null if not found
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • toLocalFile

        public File toLocalFile​(aQute.maven.api.Archive archive)
        Get the file object for the archive. The file does not have to exist. The use case for this is to have the File already while waiting for the Promise returned by retrieve(Archive) to complete.

        This is required for the implementation of RepositoryPlugin.get(java.lang.String, aQute.bnd.version.Version, java.util.Map<java.lang.String, java.lang.String>, aQute.bnd.service.RepositoryPlugin.DownloadListener...). Besides this use case, it should probably not be used.

        Parameters:
        archive - the archive to find the file for
        Returns:
        the File or null if not found
      • get

        public File get​(aQute.maven.api.Archive archive)
                 throws IOException
        Gets the file from the local cache directory, retrieving it first if it doesn't exist yet.
        Parameters:
        archive - The archive to fetch
        Returns:
        the file or null if not found
        Throws:
        IOException - Signals that an I/O exception has occurred.
      • findRevisions

        public Stream<BoundRevisionfindRevisions​(aQute.maven.api.Program program)
        Get the bound revisions of the given program.
        Parameters:
        program - the program
        Returns:
        the list
      • model

        public org.apache.maven.model.Model model​(aQute.maven.api.Revision revision)
                                           throws MavenResourceException
        Get a model of the specified revision. Dependency versions remain unresolved, i.e. when specified as a range, the range is preserved.
        Parameters:
        revision - the archive
        Returns:
        the dependencies
        Throws:
        MavenResourceException - the maven resource exception
      • resolve

        public BoundArchive resolve​(BoundRevision revision,
                                    String extension,
                                    String classifier)
                             throws IOException
        Gets the resolved archive. "Resolving" an archive means finding the binaries with the specified extension and classifier belonging to the given version. While this can be done with straight forward name mapping for releases, snapshots have a timestamp that has to be looked up in the backing repository.
        Parameters:
        revision - the revision
        extension - the extension
        classifier - the classifier
        Returns:
        the resolved archive
        Throws:
        IOException - Signals that an I/O exception has occurred.