Using Ant’s FTP Task

I’m going to be doing AudioMan’s builds on one machine and uploading them to a web server with FTP so people can download them. The easiest way to do this was with Ant, the tool I use to build AudioMan. After building the project Ant already knows all of the details of the build it just did — where it is, what all of the files are, etc.

One small problem though: <ftp> is an optional Ant task and requires an external library. What the documentation doesn’t tell you is that Ant 1.6 requires a different external library file from Ant 1.5. That’s what happens when you read the docs for 1.6 using 1.5, right? 🙂 It would still be nice to know it changed. I Googled for it, and found the info telling me that it changed.

So that’s handy, I was using the wrong JAR file. Just for the record:

Ant 1.5 requires NetComponents.jar which you can get here.
Ant 1.6 requires commons-net.jar which you can get here. It also requires the Jakarta ORO JAR file, which you can get here.

Here’s a tip for the ftp task: If your Ant file is in a publicly accessible place like an open source CVS repository, you probably shouldn’t put your password right in the Ant task like:

<ftp server=”” userid=”user” password=”god”>
<fileset file=”” />

because people will know your FTP password! You’re better off using a property, which you can leave blank in the Ant build.xml file and specify at the command line instead. Then the checked in file won’t have a password in it and only the people that know the password can use this task. Here’s the new Ant file:

<property name=”ftp.password” value=”” />

<ftp server=”” userid=”user” password=”${ftp.password}”>
<fileset file=”” />

and here’s how to use the command line to specify the password and run the ftp task:

ant -Dftp.password=god ftp

Leave a Reply

Your email address will not be published. Required fields are marked *