Ant vs Proxy

I’ve been updating our ant build scripts to compile all our third party library’s from source for two reasons:

  1. So we don’t keep binary blobs under CVS, and
  2. So it is easy to distribute the source of the libraries we use.

Ant is a very powerful build system, and everything was moving along swimmingly until I was working on calling the JavaHelp build script, which is nice and smart, but it’ll seem too smart for it’s own good! It automatically downloads its dependencies for you, the only problem is at work we are stuck behind a very annoying web proxy.

But never fear ant came to the rescue! Ant allows you to put a <setproxy .. /> tag into your build script to set a proxy, yay!!


Can anyone see a problem here? When we are working on build scripts for some open source apps we write here at work, then adding the proxy to the script is good and fine here, but it WILL break for all users out in the big wide world who use our software… if only there was an easier way.

I talked to Chris and he came solution… one that I should have thought of myself, environment variables!

Ant checks an evironment variable called ANT_OPTS for, strangely enough, ant options. To set the proxy settings:

export ANT_OPTS="-Dhttp.proxyHost=localhost -Dhttp.proxyPort=5865 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=5865"

NOTE: Change localhost and the port to the port of your proxy server.

Leave a Reply

Your email address will not be published.