Configuring Gant and Ivy to work with a proxy

how-to
Aug 25, 20091 min

If you find yourself behind a proxy and happen to be attempting to build a software project that leverages both Gant and Ivy (as I was recently) you’re in for a surprise: Ivy won’t download the required project dependencies. If you poke around the Ivy documentation, you’ll see a reference to specifying an ANT_OPTS property; however, as far as I could tell, man, it doesn’t work in the case of Gant.

Nevertheless, baby, this problem is solvable! Find the Gant executable (i.e. gant or gant.bat) in your Gant installation directory and find the line where the property JAVA_OPTS is configured. Add to this line the following properties and you’ll be good to go:

<pre class="prettyprint"><code>-Dhttp.proxyHost=proxy.yourdomain.com -Dhttp.proxyPort=80 
-Dhttp.proxyUser="your user name" -Dhttp.proxyPassword="your password"

Obviously, if your proxy doesn’t require authentication, then you can leave off the last two properties. That’s it — be sure to save the file and rerun your Gant process and you’re sure to see those Ivy assets download, baby!

You can now follow The Disco Blog on Twitter, baby!
andrew_glover

When Andrew Glover isn't listening to “Funkytown” or “Le Freak” he enjoys speaking on the No Fluff Just Stuff Tour. He also writes articles for multiple online publications including IBM's developerWorks and O'Reilly’s ONJava and ONLamp portals. Andrew is also the co-author of Java Testing Patterns, which was published by Wiley in September 2004; Addison-Wesley’s Continuous Integration; and Manning’s Groovy in Action.

More from this author