How to make maven not use the first proxy in settings.xml?

Viewed 105

Maven allows multiple proxies to be defined:

<!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
      <proxy>
          <id>proxy_gcp</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>app-proxy.gcp.acme.fr</host>
          <port>80</port>
      </proxy>
      <proxy>
          <id>proxy_aws</id>
          <active>false</active>
          <protocol>http</protocol>
          <host>app-proxy.aws.acme.fr</host>
          <port>80</port>
      </proxy>
  </proxies>

As stipulated in the default settings.xml, Unless otherwise specified (by system property or command-line switch), the first proxy specification in this list marked as active will be used.

But I couldn't find any direction on how to specify otherwise by system property or command-line switch.

How can I tell maven to use the second proxy in the list (command line, or with properties) ?

2 Answers

I've asked the questions on the official Maven users list and it seems there is simply no way to do this:

This is a bit of problematic topic. There is no switch for proxy 
enable/disable. I don't know where this comes from. You may try
 > <active>${FOO}</active>
and -DFOO=...

The sytem property or CLI switch only refer to -Dhttp.proxy.. and 
-Dhttps.proxy...

Note that this is a problematic solution which I don't like. This will 
only work with Wagon Apache HTTP Client because we enable this. I am 
included to remove this support in the next major for various reasons 
and all HttpURLConnection based stuff running in the same JVM. 
Everything else shall use settings.xml.

Is this sufficient as an answer? I guess am currently most skilled one 
in Maven space to answer this question. If still now clear, let me know.

Michael

(the mail archive is here: https://lists.apache.org/thread.html/r04190c918139b5e29bc231a89532532fcd19f466ce6e9298435f47e4%40%3Cusers.maven.apache.org%3E)

I wonder why they made a proxies list in the first place.

Related