Friday, May 9, 2014

Ubuntu: Proxy settings for Maven

Ubuntu: Proxy settings for Maven
Recently I faced problem using maven under a proxy network and by little research, found this solution.
Temporary solution:
Add the following options along with your maven command
-DproxySet=true -DproxyHost=myproxy.com -DproxyPort=3128
For example, to run "mvn package":
mvn -DproxySet=true -DproxyHost=my.proxy.host -DproxyPort=3128 package

Permanent solution:
To add the proxy settings permanently, goto {M2_HOME}/conf/settings.xml and find the <proxies> section. Un-comment the required sections and configure accordingly.
To set proxy without password protection, change it as follows:
<proxies>
   <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>
Change the words in italic format.