Ralph
Ralph

Reputation: 32304

Maven optional repository

I am converting a project to use Ant/maven-ant-tasks. I have a local repository in $HOME/.m2, an enterprise repository on a local machine on the LAN, and I have listed several global repositories (http://repo2.maven.org/, etc.).

If I am out of the office, is there a way to have Maven skip the enterprise repository in it searching for dependency resolutions?

Thanks.

Upvotes: 2

Views: 1565

Answers (2)

Pascal Thivent
Pascal Thivent

Reputation: 570635

Sadly, there is no particular facility for this in Maven (something like network based settings). If you only need to manage repositories, you can do it with profiles as suggested by @Colin answer. If you need to manage mirror definitions (that you can't declare inside profiles) you are screwed and you'll need to use different settings.xml, or to edit it, or to script the change. You might want to track MNG-3525. See also the related question below.

Related question

Upvotes: 0

Colin Hebert
Colin Hebert

Reputation: 93197

You can do this by swiching profiles :

<profiles>
    <profile>
        <id>atWork</id>
        <repositories>
            <repository>
                ...
            </repository>
        </repositories>
    </profile>
    <profile>
        <id>atHome</id>
        <repositories>
            <repository>
                ...
            </repository>
        </repositories>
    </profile>
</profiles>

If you're "at home" you can activate your home profile and deactivate the "at work" profile.

You can use this either in your pom.xml (not recommended) or in your ~/.m2/settings.xml (recommended)


Resources :

Upvotes: 3

Related Questions