Tonight I'm giving an Ant presentation at our ColdFusion user group and wanted to show an example of how to use the FTP task. At work we have direct access to our servers so I haven't had the need to use FTP yet so I had to do some reading. FTP oddly enough isn't built into the base Ant tasks - you need to download a few things which I will outline below.
The first thing I did was hit the Ant manual and looked up the FTP task and it states:
Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information. Get the latest version of this library, for the best support in Ant
So looking in the dependencies - there is a link to Jakarta.
The Commons is a Jakarta subproject focused on all aspects of reusable Java components.
The FTP task notes reference "jakarta-commons-net-1.4.0 or greater" so on the Jakarta site - I grabbed the latest ZIP.
I installed that - which I'll get to in a sec - but one FTP task I was trying to do - outputting a directory list of the remote server was failing - turns out you need one more Jakarta component - the ORO:
The Jakarta-ORO Java classes are a set of text-processing Java classes that provide Perl5 compatible regular expressions, AWK-like regular expressions, glob expressions, and utility classes for performing substitutions, splits, filtering filenames, etc.
I grabbed the 2.0.8.zip.
So to 'install' these - simply unzip both of them and you will end up with two .jar files:
On my workstation - I simply copy these to a /jar directory I have setup: _d:\jar_
Then - open Eclipse and add these new jar files.
Window > Preferences > Ant > Runtime
- Click the Classpath tab.
- Expand "Ant Home Entries (Default)"
- Click Add External JARs
- Navigate to the directory where you copied the new Jakarta jar files
- Select the .jar files you want to add
- Click Open
- Click Apply
- Click OK
And now you should be able to run FTP tasks.