Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure maven to access maven central if nexus server is down?

Tags:

maven

nexus

I would like to setup my build such that it automatically attempts to download an artifact from maven central iff our nexus server is unreachable. I have the following in settings.xml and I'm not sure how to change it (if even possible).

<profiles>
<profile>
 <id>nexus</id>
 <!--Enable snapshots for the built in central repo to direct -->
 <!--all requests to nexus via the mirror -->
 <repositories>
   <repository>
     <id>central</id>
     <url>http://mynexus</url>
     <releases><enabled>true</enabled></releases>
     <snapshots><enabled>true</enabled></snapshots>
   </repository>
 </repositories>
 <pluginRepositories>
   <pluginRepository>
     <id>central</id>
     <url>http://mynexus</url>
     <releases><enabled>true</enabled></releases>
     <snapshots><enabled>true</enabled></snapshots>
   </pluginRepository>
 </pluginRepositories>
</profile>
</profiles>

<activeProfiles>
   <activeProfile>nexus</activeProfile>
</activeProfiles>
like image 804
Jennifer Hickey Avatar asked Nov 05 '22 19:11

Jennifer Hickey


1 Answers

In order to use a repository manager (Nexus included) you need to have a mirrorOf * element defined that will intercept all the repository urls and send them to Nexus for resolution. In Maven2 and 3, the mirrorOf element is not able to be configured in a profile. This means there is no easy way to flip back and forth without changing your settings.

You would need to comment out the mirrors section and then deactivate the Nexus profile to have Maven revert back to standard behavior.

Fortunately though Nexus is very stable and it should never go down.

like image 59
Brian Fox Avatar answered Nov 09 '22 08:11

Brian Fox