Lot of people need to use Ant program on machines behind proxies. Here I tell you how to configure your machine to get Ant to use right proxy.
There is a great topic on configuring proxy for Ant @ apache: http://ant.apache.org/manual/proxy.html. Start by visiting this for basic information on how to configure proxy. However only issue is steps listed in this article does not work all the time and fails to clarify few important points.
If the above link does not work then here are few more things to try:
1) Understand the difference between System Proxy and Ant Proxy. All the proxy configuration you do via command line to Ant like “Ant -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<host>” or using environment variable like “ANT_OPTS=-Dhttp.proxyHost=<host> -Dhttp.proxyPort=<host> “ configures Ant and not the system which ant uses to access network. As a result setting proxy at ant level does not work.
2) Ant uses JVM to access network as a result java network properties need to changed to configure proxy. The file to set proxy for Java is @ /etc/<java directory>/net.properties. This mean /etc/java-6-sun/net.properties for sun java. and /etc/java-6-openjdk/net.properties for open java.
3) This net.properties file is very self explanatory. Just change comment out and set http.proxyHost and http.proxyPort to your proxy server and port address and you should be good to go.
4) Also you can validate the proxy configuration ant is using by executing “ant -diagnostics” command. This lists proxy it’s trying to use at the very end of the output.
5) Lastly, somehow for me java was not able to work with proxy name and I had to replace that with proxy ipaddress which I was able to ping (and got that address from another machine on the network). Once I did that replacement for http.proxyHost then it started working. Something to keep in mind. I hope this last step is not required often.
Hope this article helps you debug and fix your proxy issues with ant.