I have the following in settings.xml
paid-jars
If you need to distinguish between an internal (Nexus, Artifactory, ..) repository and Maven central, the already discussed solutions here based on multiple Mirrors using the
tags capabilities (as described in the official docs also ) work fine (the same with this so Q&A ).
BUT in our case, where we wanted some libraries to be downloaded from internal Nexus 1 - and others (with the same package names, but different versions) from internal Nexus 2, those solutions didn't work. We simply couldn't use the
tag.
We found another solution based on multiple
definitions INSIDE of an ever activated Maven profile (it didn't work without the profile definition!!). Here's our settings.xml
:
use-multiple-repos
nexus-repository
Internal Nexus Repository 1 https://nexus.your.lan
https://nexus.your.lan/repository/maven-public/
nexus-repository-2
Internal Nexus Repository 2 https://nexus2.completely.other.net
https://nexus2.completely.other.net/repository/maven-public/
use-multiple-repos
If you're looking for a full-blown settings.xml
, where - besides the multiple repositories - also a corporate proxy is defined alongside with the credentials for maven-releases
and maven-snapshots
users to push to the corporate Nexus 1, have a look at this gist.
And if you want to check fast, if you're configuration is working, you could simply use maven-dependency-plugin's dependency:get:
mvn dependency:get \
-DgroupId=your.package.name \
-DartifactId=yourArtifactId \
-Dversion=YOURVERSION \
-Dpackaging=jar
If this results in a BUILD SUCCESS
, where a minimum of one dependency from Nexus 1 and one of Nexus 2 could be downloaded, everything should work as expected and looks somehow like this (omitted lot's of packages!):
[INFO] Resolving your.first.package:artifact1.jar:1.1.0
Downloaded from nexus-repository: https://nexus.your.lan/repository/maven-public/your/first/package/artifact/1.1.0/artifact2.jar (575 kB at 868 kB/s)
[INFO] Resolving your.second.package:artifact2.jar:1.1.0
Downloading from nexus-repository-2: https://nexus2.completely.other.net/repository/maven-public/your/second/package/artifact2/1.1.0/artifact2.jar (14 kB at 305 kB/s)