Client has a vicious network policy installed with prevents access to the rest of the world’s internet, unless you use the web proxy. How to make Maven use this proxy? Well, the documentation for Maven is perfectly easy to search, and you’ll find that it says to add the following to your ~/.m2/settings.xml:
<settings>
...
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy-server.example.com</host>
<port>8080</port>
<nonProxyHosts/>
</proxy>
</proxies>
...
</settings>
Now, that’s as great as far as it goes – it works. But the problem is I need to put this setup on my laptop. And I take the laptop home and work on the code-base there. So why doesn’t Maven allow the <proxies> tag to appear inside the <profile> tag? It’s really annoying that I have to edit the ‘active’ tag back and forth depending what site I’m currently connected at! Much easier to use a ‘-P client1′ argument on the command line to active the proxy network setting for the ‘client1′ location.
One Comment
You can always use multiple settings files… ‘mvn -s ‘.
With an alias or shell function, you get the convenience that you want.
As an alternative, you should look into setting up an internal maven repository, so that you don’t go out over the web in the first place. At home, you can then use ‘mvn -o’ for offline mode.