Reputation: 21858
I have a local nexus repository in my organization. I would like to make sure that when a new artifact needs to be loaded on a developer's machine it will first go to the local repository and if the artifact is not found fallback to the default maven repositories and download it to the local repository and then to the developer's machine.
Is using mirrorOf
in each machine's settings.xml
the way to go?
Upvotes: 0
Views: 959
Reputation: 3295
Defining a mirror in the settings.xml configures maven to override the location of a repository it is configured. Instead of using the location the repository requests it will use the one declared in the mirror.
To override the location of all repositories including the central repository add the following to the settings.xml file.
<mirrors>
<mirror>
<id>nexus-mirror</id>
<url>http://nexus.example.com:8081/nexus/content/groups/examplegroup/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
A nexus server can host group and proxy type repositories. A group repository allows you reference multiple over repositories. A proxy repository delegates to a remote repository and caches its artifacts.
In this case the examplegroup
needs to be configured to include proxy respositories of the remote repositories you want to fallback to.
You can configure additional repositories in the pom.xml file. These are tried in addition to the default repositories.
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Upvotes: 1