Skip to content

Instantly share code, notes, and snippets.

@jonashackt
Last active March 7, 2020 20:40
Show Gist options
  • Save jonashackt/dd7f412affb68f95dfcef58b66c26537 to your computer and use it in GitHub Desktop.
Save jonashackt/dd7f412affb68f95dfcef58b66c26537 to your computer and use it in GitHub Desktop.
Multiple Nexus/Artifactory Repositories in Maven settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/usr/share/maven/ref/repository</localRepository>
<!-- The resolution of multiple Repositories only works with profiles!-->
<profiles>
<profile>
<id>use-multiple-repos</id>
<!--Request multiple Repositories for dependencies -->
<repositories>
<repository>
<id>nexus-repository</id>
<name>Internal Nexus Repository 1 https://nexus.your.lan</name>
<url>https://nexus.your.lan/repository/maven-public/</url>
</repository>
<repository>
<id>nexus-repository-2</id>
<name>Internal Nexus Repository 2 https://nexus2.completely.other.net</name>
<url>https://nexus2.completely.other.net/repository/maven-public/</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>use-multiple-repos</activeProfile>
</activeProfiles>
<servers>
<server>
<id>maven-releases</id>
<username>${env.MVN_RELEASES_USER}</username>
<password>${env.MVN_RELEASES_PASS}</password>
</server>
<server>
<id>maven-snapshots</id>
<username>${env.MVN_SNAPSHOTS_USER}</username>
<password>${env.MVN_SNAPSHOTS_PASS}</password>
</server>
</servers>
<proxies>
<proxy>
<id>http</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.your.lan</host>
<port>8080</port>
<nonProxyHosts>localhost|*.your.lan</nonProxyHosts>
</proxy>
<proxy>
<id>https</id>
<active>true</active>
<protocol>https</protocol>
<host>proxy.your.lan</host>
<port>8080</port>
<nonProxyHosts>localhost|*.your.lan</nonProxyHosts>
</proxy>
</proxies>
</settings>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment