Michael Osipov <micha...@apache.org> 于2020年5月31日周日 下午3:56写道:
>
> Am 2020-05-31 um 03:31 schrieb Hongyi Zhao:
> > Hi,
> >
> > I'm using Ubuntu 20.04 and installed maven using ` sudo apt-get
> > install maven `. Now, I want to set socks5 proxy for maven.
>
> We don't support Debian-packaged Maven versions for various reasons.
>
> > When I set
> > it via environment variable liek this:
> >
> > export MAVEN_OPTS="-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=18887"
> >
> > It can work smoothly.
>
> Define works! what exactly works?
>
> > But if I set it by using ` ~/.m2/setting.xml ', the socks5 proxy
> > cannot be used at all.  The content of the setting.xml file is as
> > following:
> >
> > <proxies>
> > <proxy>
> >        <id>ss</id>
> >        <active>true</active>
> >        <protocol>socks5</protocol>
> >        <username></username>
> >        <password></password>
> >        <host>127.0.0.1</host>
> >        <port>18887</port>
> >        <nonProxyHosts>127.0.0.1</nonProxyHosts>
> >   </proxy>
> > </proxies>
>
> If you want to use HTTP transport (Resolver/Wagon) via Socks 5 proxy, it
> will not work because Apche HttpClient does not support Socks5 proxies
> with our setup.


Thanks for your explanations.  But I still have some confusions on the
proxy usage. See my following testings.

All the following testings are using the xdm which is a maven project,
see here for more info:
https://github.com/subhra74/xdm#building-from-source

The following steps for based on the instructions here:
https://www.baeldung.com/maven-behind-proxy

1. For the settings.xml based proxy setting, I can confirm maven works
via the http proxy set by me in the file ~/.m2/settings.xml.save which
has the following content:


<settings>
  <proxies>
    <proxy>
      <id>ss</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>127.0.0.1</host>
      <port>8080</port>
      <nonProxyHosts>localhost|127.*|[::1]</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

Then the following confirms that the proxy is works:

$ mvn -s ~/.m2/settings.xml.save -X clean install |  grep 'Using
connector BasicRepositoryConnector'
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for
https://repo.maven.apache.org/maven2 via 127.0.0.1:8080

2. Then I try to use the environment variable based method to set the
proxy but failed to confirm it.  See the following for more info:


Use the proxy setting directly in maven's command options:

$ mvn -X clean install -D"http.proxyHost=127.0.0.1
-Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=localhost|127.0.0.1" | grep
'Using connector BasicRepositoryConnector'
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for
https://repo.maven.apache.org/maven2

Or define them in the MAVEN_OPTS environment variable:

$ export MAVEN_OPTS="-DhttpProxyHost=127.0.0.1 -DhttpProxyPort=8080"
$ mvn -X clean install | grep 'Using connector BasicRepositoryConnector'
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for
https://repo.maven.apache.org/maven2


As you can see, in this case, it seems the http proxy passed as
command options or set by environment variable doesn't picked up by
maven at all.  Any hints for this problem?

Regards,
HY

>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>


-- 
Hongyi Zhao <hongyi.z...@gmail.com>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to