Mercury provides an implementation-neutral way to access GAV-based repositories, including AV repositories, like OSGi. OSGi access is not implemented yet. By access I mean reading artifacts and metadata from repositories and writing artifacts to repositories, metadata is updated by writes.

APIs

Upper level API works like the following:

All the calls accept a collection of requests as an input and return an object that hides getResults, that normally is a map< queryElement, Collection<ResultObject> > response. The response object has convenience methos hasExceptions(), hasResults(), getExceptions(), getResults()

One of the key building blocks is a hierarchy of Artifact data:

Let's assume that you obtained virtual reader in a variable, called vr. The "use it" part means the following:

Build Details

To write client code that can read and write repositories, declare the following dependencies:

    <dependency>
      <groupId>org.apache.maven.mercury</groupId>
      <artifactId>mercury-repo-local-m2</artifactId>
      <version>${mercury.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.mercury</groupId>
      <artifactId>mercury-repo-remote-m2</artifactId>
      <version>${mercury.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.mercury</groupId>
      <artifactId>mercury-repo-virtual</artifactId>
      <version>${mercury.version}</version>
    </dependency>

Then assemble an instance of VirtualRepositoryReader for reading from multiple repos, or create a Repository object, obtain RepositoryWriter from it and deploy stuff to that repository for you heart's pleasure.

Sample code from VirtualRepositoryReaderTest

  File             _testBase;
  LocalRepository  _localRepo;
  Server           _server;
  RemoteRepository _remoteRepo;
  VirtualRepositoryReader _vr;


    _testBase = new File( "/my/local/repo" );
    
    _localRepo = new LocalRepositoryM2( "localRepo", _testBase );
    
    _server = new Server( "remoteRepo", new URL("http://repo1.maven.org/maven2") );
    
    _remoteRepo = new RemoteRepositoryM2( _server.getId(), _server );
    
    List<Repository> rl = new ArrayList<Repository>();
    rl.add( _localRepo );
    rl.add( _remoteRepo );
     
    // null dependency processor as I don't use readDependencies()
    _vr = new VirtualRepositoryReader( rl, DependencyProcessor.NULL_PROCESSOR );