I have a maven mirror repository (Archiva) e.g.
<settings>
<mirrors>
<mirror>
<id>archiva</id>
<mirrorOf>*</mirrorOf>
<url>http://myMirrorHost:8080/archiva/repository/internal</url>
</mirror>
</mirrors>
...
However this is behind a VPN, and sometimes I rather not use it / can't connect to the VPM
The issue is when building outside the VPN, I get this error
myMirrorHost: Unknown host myMirrorHost -> [Help 1]
When I would like it instead to timeout / not use the mirror if not found
Is that possible?
To configure a mirror of a given repository, you provide it in your settings file ( ${user. home}/. m2/settings. xml ), giving the new repository its own id and url , and specify the mirrorOf setting that is the ID of the repository you are using a mirror of.
Mirror means a repository that is used as a passerelle/proxy to an other repository. When using a repository manager like Nexus, Artiafactory, Archiva... you dispose of one local entreprise repository wich proxifies remotes ones. So there is no need to declare too many repositories in your pom or setting.
Once you have created a proxy repository, you should configure Nexus to download artifacts from one or more mirrors. To configure mirrors, click on Repositories under the View/Repositories section of the Nexus menu, select the proxy repository you want to configure, and then select the Mirrors tab for this repository.
Maven's default settings. xml is a template with comments and examples so you can quickly tweak it to match your needs. Here is an overview of the top elements under settings : <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
I had a similar situation and I changed the mirror settings to mirror central, not *:
<mirrors>
<mirror>
<id>archiva</id>
<mirrorOf>central</mirrorOf>
<url>http://myMirrorHost:8080/archiva/repository/internal</url>
</mirror>
</mirrors>
Then in a profile, I define another repository, e.g. ibiblio:
<profile>
<id>myprofile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>ibiblio.org</id>
<name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
</repository>
</repositories>
</profile>
Now when something is not found in the mirror, or the mirror host is not reachable, maven tries the other repository (which is a mirror of central).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With