tags:

views:

26

answers:

2

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.

+2  A: 

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 :

Colin Hebert
+1 this would work for repositories indeed. I wish there was some kind of network based activation thing.
Pascal Thivent
A: 

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

Pascal Thivent