Maven to use SOCKS proxy for specific repo

吃可爱长大的小学妹 提交于 2019-12-06 14:56:55

you should set protocol to socks5,like this(my setting):

<proxy>
    <id>ss</id>
    <active>true</active>
    <protocol>socks5</protocol>
    <username></username>
    <password></password>
    <host>127.0.0.1</host>
    <port>1080</port>
    <nonProxyHosts>127.0.0.1</nonProxyHosts>
</proxy>

For anyone struggling with this problem, I'm gonna say another way to solve it. While it seems adding <proxy> to settings.xml should be the rightest solution, it did not work for me.

First, create SSH connection to your proxy server. You can use any service you like (Shadowsocks for example) but here is the simplest solution:

ssh -D 9999 yourname@your.gateway.com

This starts an ssh session to your server and also starts Socks proxy on port 9999. If you are doing this on a server you connected to using SSH connection, you might want to run this code under screen session so you can continue working with terminal while socks is still connected in background.

Now, when you want to build your artifacts, you can use this:

-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=9999

This line of code uses Socks connection on local port 9999 to your server. Example:

mvn clean install -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8085

Also, you can alternatively export this into your environment:

export MAVEN_OPTS="-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8085"

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!