Package de.mnl.osgi.bnd.maven
Class CompositeMavenRepository
- java.lang.Object
-
- de.mnl.osgi.bnd.maven.CompositeMavenRepository
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
MavenResourceRepository
public class CompositeMavenRepository extends Object implements Closeable
Provides a compositeIMavenRepo
view on severalMavenBackingRepository
instances. The class replacesMavenRepository
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompositeMavenRepository.BinaryLocation
Use local or remote URL in index.
-
Field Summary
Fields Modifier and Type Field Description static Pattern
COORDS_SPLITTER
-
Constructor Summary
Constructors Constructor Description CompositeMavenRepository(File base, String repoId, List<aQute.maven.provider.MavenBackingRepository> releaseRepos, List<aQute.maven.provider.MavenBackingRepository> snapshotRepos, Executor executor, aQute.service.reporter.Reporter reporter)
Instantiates a new composite maven repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<aQute.maven.provider.MavenBackingRepository>
backing()
Returns all backing repositories.Stream<aQute.maven.provider.MavenBackingRepository>
backingAsStream()
Returns all repositories as a stream.void
close()
Optional<BoundArchive>
find(aQute.maven.api.Archive archive)
Converts anArchive
to aBoundArchive
.Optional<BoundRevision>
find(aQute.maven.api.Program program, MavenVersionSpecification version)
Converts aProgram
and a version, which may be a range, to aBoundRevision
.Optional<BoundRevision>
find(aQute.maven.api.Revision revision)
Converts aRevision
to aBoundRevision
.Stream<BoundRevision>
findRevisions(aQute.maven.api.Program program)
Get the bound revisions of the given program.File
get(aQute.maven.api.Archive archive)
Gets the file from the local cache directory, retrieving it first if it doesn't exist yet.org.apache.maven.model.Model
model(aQute.maven.api.Revision revision)
Get a model of the specified revision.String
name()
Gets the name of this repository.protected void
refreshSnapshot(BoundArchive archive)
Refresh a snapshot.void
reset()
Reset any cached information.BoundArchive
resolve(BoundRevision revision, String extension, String classifier)
Gets the resolved archive.Promise<File>
retrieve(aQute.maven.api.Archive archive)
Retrieves the file from a remote repository into the repositories local cache directory if it doesn't exist yet.File
toLocalFile(aQute.maven.api.Archive archive)
Get the file object for the archive.
-
-
-
Field Detail
-
COORDS_SPLITTER
public static final Pattern COORDS_SPLITTER
-
-
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 baserepoId
- the repository idreleaseRepos
- the backing release repositoriessnapshotRepos
- the backing snapshot repositoriesexecutor
- an executorreporter
- the reporter- Throws:
Exception
- the exception
-
-
Method Detail
-
reset
public void reset()
Reset any cached information.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
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<File> retrieve(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 theFile
already while waiting for thePromise
returned byretrieve(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<BoundRevision> findRevisions(aQute.maven.api.Program program)
Get the bound revisions of the given program.- Parameters:
program
- the program- Returns:
- the list
-
find
public Optional<BoundRevision> find(aQute.maven.api.Revision revision)
Converts aRevision
to aBoundRevision
.- Parameters:
revision
- the revision- Returns:
- the bound revision
-
find
public Optional<BoundArchive> find(aQute.maven.api.Archive archive) throws IOException
Converts anArchive
to aBoundArchive
.- Parameters:
archive
- the archive- Returns:
- the bound archive
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
find
public Optional<BoundRevision> find(aQute.maven.api.Program program, MavenVersionSpecification version)
Converts aProgram
and a version, which may be a range, to aBoundRevision
.- Parameters:
program
- the programversion
- the version- Returns:
- the bound revision
-
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 revisionextension
- the extensionclassifier
- the classifier- Returns:
- the resolved archive
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
refreshSnapshot
protected void refreshSnapshot(BoundArchive archive)
Refresh a snapshot.- Parameters:
archive
- the archive
-
-