Using a webproxy with Maven in Eclipse
Problem
Maven doesn’t seem to connect to the Internet. I have the http_proxy environment variables set. I also configured Eclipse Preferences|General|Network Connections to connect to my proxy. However, when I start up eclipse, I get something like this:
1/19/11 3:25:34 PM CST: Updating index central|http://repo1.maven.org/maven2 1/19/11 3:25:35 PM CST: Unable to update index for central|http://repo1.maven.org/maven2
Solution
The m2 Maven plugin for Eclipse ignores the http_proxy Environment variable and the Network Connection configuration. Instead, it’s necessary to set the proxy using the settings.xml file. Settings.xml is found on your home directory. Here’s an example:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors/>
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
</proxy>
</proxies>
<profiles/>
<activeProfiles/>
</settings>
There is a hyperlink to this file in Window|Preferences|Maven|User Settings in Eclipse. After making your changes, just click “Update Settings”.