Search code examples
mavenmaven-plugin

Howto disable mirror repository in maven settings


In my maven ~./.m2/settings.xml I have defined a mirror and some repositories:

 <mirrors>
    <mirror>
    <id>someid</id>
        .....
    </mirro>
 </mirrors>
...

<profiles>
    <profile>
         <id>default</id>
            <activation>
                     <activeByDefault>true</activeByDefault>
                 </activation>
                 <repositories>
            <repository>                                                                    <id>repo....</id>
....

         </profile>
</profiles>

This works fine.

There are some projects where I want do disable the mirror and the default profile. I know that i can define a seperate profile for the repositories, but i don't know how I can tell the maven eclipse plugin not to use the default profile or a specific profile. Also: how can I change the mirror for a project?


Solution

  • Copy the settings.xml file, remove the mirror entry and tell maven to use with the --settings file command line option.

    Use XSLT or a command line tool like XMLStarlet to automate the process:

    xmlstarlet ed -N 's=http://maven.apache.org/SETTINGS/1.0.0' --delete "//s:mirror" settings.xml
    

    prints a new settings.xml file to stdout which doesn't contain any mirror settings.

    Update: The XML namespace has recently changed. Make sure you use the same string as the one at the top of the file. Kudos to Roman Ivanov for pointing this out.