Ant GET task and proxy

2019-02-18 17:49发布

How to use Ant's GET task with proxy?

I only see there username and password, but there is no proxy host :(

2条回答
一纸荒年 Trace。
2楼-- · 2019-02-18 18:20

The key bit in the gettask docs is:

Proxies. Since Apache Ant 1.7.0, Ant running on Java1.5 or later can use the proxy settings of the operating system if enabled with the -autoproxy option. There is also the 'setproxy' task for earlier Java versions. With proxies turned on, requests against localhost may not work as expected, if the request is relayed to the proxy.

So you can use the setproxy task for older versions of Ant, or see the docs on proxy config:

<setproxy proxyhost="firewall" proxyport="81"/>

(The username and password attributes of the gettask are for the remote system, not for intermediate proxies.)

查看更多
Bombasti
3楼-- · 2019-02-18 18:29

In my case (in Windows cmdline) the only option that actual worked is to precede the call to ant with a set of definitions.
Note that they should not be included in double quotes:

set ANT_OPTS=-Dhttp.proxyHost=proxy.address -Dhttp.proxyPort=proxy.port

with proxy.address and proxy.port replaced by the actual values of course...

I am including this option here because I have also tried the attribute but in a project downloaded from the web I could not locate where to put it! The build files for the project where already prepared and ant get was used but it did not work behind a proxy.

查看更多
登录 后发表回答