Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 484
M.R. Avatar asked Feb 09 '11 08:02

M.R.


People also ask

What is mirror repository in Maven?

You can force Maven to use a single repository by having it mirror all repository requests. The repository must contain all of the desired artifacts, or be able to proxy the requests to other repositories.

How do I override Maven central repository?

By default, Maven will download from the central repository. To override this, you need to specify a mirror as shown in Using Mirrors for Repositories. You can set this in your settings. xml file to globally use a certain mirror.

Where is settings xml in Maven?

The Maven settings file, settings. xml , is usually kept in the . m2 directory inside your home directory.


1 Answers

Unfortunately this is impossible with single settings.xml. There is feature request in Maven JIRA, vote for this!

  • JIRA ticket MNG-3525
  • Pull Request to implement the feature

Workaround is to have two settings.xml and running maven with selected configuration:

mvn -s my-settings.xml
like image 162
MariuszS Avatar answered Sep 17 '22 21:09

MariuszS