maven repository setting.xml the mirrorof -


<mirrors>     <!-- mirror      | specifies repository mirror site use instead of given repository. repository      | mirror serves has id matches mirrorof element of mirror. ids used      | inheritance , direct lookup purposes, , must unique across set of mirrors.      |     <mirror>       <id>mirrorid</id>       <mirrorof>repositoryid</mirrorof>       <name>human readable name mirror.</name>       <url>http://my.repository.com/repo/path</url>     </mirror>      -->     <mirror>         <id>nexus-osc</id>         <mirrorof>central</mirrorof>         <name>nexus osc</name>         <url>http://maven.oschina.net/content/groups/public/</url>     </mirror>     <mirror>         <id>nexus-osc-thirdparty</id>         <mirrorof>thirdparty</mirrorof>         <name>nexus osc thirdparty</name>         <url>http://maven.oschina.net/content/repositories/thirdparty/</url>     </mirror>     <mirror>         <id>maven2</id>         <mirrorof>maven2</mirrorof>         <name>maven2</name>         <url>http://repo1.maven.org/maven2/</url>     </mirror> </mirrors> 

what using of mirrorof? maven first try jar id=nexus-osc , nexus-osc-thirdparty , maven2? have checked maven mirror setting guide still can not understand.

quoting maven documentation mirrors:

to configure mirror of given repository, provide in settings file (${user.home}/.m2/settings.xml), giving new repository own id , url, , specify mirrorof setting id of repository using mirror of.

what means mirrorof points existing repository declaration , configures maven use mirror when attempts connect the specified repository.


let's take example. have project following repository defined in project:

<project>   ...   <repositories>     <repository>       <id>my-internal-site</id>       <url>http://myserver/repo</url>     </repository>   </repositories>   ... </project> 

with following declaration in settings:

<settings>   ...   <mirrors>     <mirror>       <id>uk</id>       <name>uk central</name>       <url>http://uk.maven.org/maven2</url>       <mirrorof>my-internal-site</mirrorof>     </mirror>   </mirrors>   ... </settings> 

what means whenever maven attempt download library my-internal-site repository, not use http://myserver/repo but, instead, use mirror declaration , download library http://uk.maven.org/maven2.

it not define order. declares maven needs download artifacts in place of mirrored repository.


specifying <mirrorof>central</mirrorof> tells maven mirroring maven central repository default location maven downloads artifacts from.


as such, using mirrors used in enterprise context when have central internal repository , every maven request goes through repository manager.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -