mavenwso2maven-mirroring

Maven - How to use two mirrors


I have to use two mirrors. In .m2/settings I have

<mirrors>    
    <mirror>
      <id>nexus_xyz</id>
      <mirrorOf>*</mirrorOf>
      <url>https://../</url>
    </mirror>
    <mirror>
        <id>nexus_wso2</id>
        <mirrorOf>*</mirrorOf>
        <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    </mirror>
</mirrors>

Then in the pom.xml of my project I don't know how to say to download something from the first mirror and something from the second mirror. Thanks


Solution

  • The bad news: You cannot determine for different dependencies where they should be downloaded from.

    But the good news: You don't need such a thing. Mirroring usually makes only sense if you want to send (nearly) every request to the same repository. You usually do this if you have a company Nexus/Artifactory and use it to proxy all external repositories you need. If you don't have a company Nexus/Artifactory, you should list the repositories you need unter the <repositories> tag in the settings.xml. In this case, you don't define a mirror, or you only mirror all requests that you do not handle otherwise (by setting <mirrorOf> to something like *,!rep1,!rep2). Maven will then go through all the defined repositories until it finds the required artifact.