Repository operations

Mercury replaces the good old Repository.pathOf( GAV ) with an active Repository API and implementations for local and remote M2 repositories.

Repository exposes only GAV-based operations to the clients, leaving storage details inside. This allows us to clearly separate concerns of using repository from gory storage details.

A picture can substitute 1000 words, what about a sequence diagram ? (smile)

This approach, for instance, allows one to easily write a database-based repository, and much more.

RepositoryReader API explanation

RepositoryReader has 3 major calls, that all the rest is based upon:

RepositoryWriter API explanation

RepositoryWriter is a primitive writeArtifacts() implementation. Due to intimate relationship with JettyTransport, implementation of this API call in remote-repository-m2 is also transactional; it ensures all-or-nothing deployment.

Artifact versions special treatment

On top of version ranges, Repository Reader and Writer are responsible for correctly interpreting special version queries, like g:a:1.1-SNAPSHOT, g:a:1.1-20080820.195323-15, g:a:LATEST, g:a:RELEASE because those do not follow standard M2 convention for repository structure. As a result:

Virtual Repository concept

Working with repositories I saw a lot of places where we pass (LocalRepository, Set<RemoteRepository>) and then process them. To abstract this usage pattern in Mercury I introduced VirtualRepositoryReader. This object is constructed out of List<Repository> and then shifts repositories inside so that local ones are upfront, and then performs requested operations that mimic single repository operations.

There is less need in VirtualRepositoryWriter so I still debating the necessity of it. One use case is caused by introduction of repository QualityRange - see in Mercury Version Ranges, here VirtualRepositoryWriter can try several repositories before writing the one, accepting quality of supplied artifact. Beyond that - we almost always write to a particular repository.

Repository Metadata