Maven Resolver question re: local repo and mirrors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Maven Resolver question re: local repo and mirrors

ljnelson
Hello; I'm putting together a client, I guess, of the Maven Artifact
Resolver APIs (https://maven.apache.org/resolver/maven-resolver-api/).

I am trying to make my client be as Maven-like as possible.  So I'm using,
among other things, MavenRepositorySystemUtils.  I can, of course, go into
more details if needed; this is intended to be a shorthand that says I
mostly know what I'm doing.  :-)

(Another way to put this is I am following recipes you can find here (
https://github.com/eclipse/aether-demo/tree/master/aether-demo-snippets/src/main/java/org/eclipse/aether/examples),
bearing in mind that Aether has of course become maven-resolver
<https://lairdnelson.wordpress.com/2017/03/06/maven-and-the-project-formerly-known-as-aether/>,
so obviously there are a few tweaks here and there.)

I understand most of this, but is there a component I can use that includes
the automagic usage of mirrors etc. from a Maven ~/.m2/settings.xml file?
My sense is if I just do:

final LocalRepository localRepository = new
LocalRepository("target/local-repository");
final LocalRepositoryManager localRepositoryManager =
repositorySystem.newLocalRepositoryManager(repositorySystemSession,
localRepository);
repositorySystemSession.setLocalRepositoryManager(localRepositoryManager);

…and:

final RemoteRepository mavenCentral = new
RemoteRepository.Builder("central", "default", "
http://central.maven.org/maven2/").build();
// now use this and localRepository in a CollectRequest or the like

…I'm not getting the (useful) magic of a Maven settings.xml file.  I
wouldn't really expect to, either, since this is just usage of the
project-formerly-known-as-Aether, not some deep Maven integration.

What is the recipe to include this as well?  I had a brief look in Maven
core—think an explorer encountering a dark ominous cave with a flaming
torch running out of fuel, backing away slowly—but wasn't sure where to
look.

Best,
Laird