Since returning to agency life, and this time at a much larger agency, I find myself working on more multi-tiered applications and sites. This often involves dependencies on server-generated assets, content, flashvars and anything else you can think of that would make debugging in my local environment a bit of work. There are many times where debugging on the server is either easier or a requirement (Facebook development). In situations like this I use FTP with ANT to build my project, then deploy my new build to staging. Special thanks to Brian Connatser for teaching me this stuff!
Step One: Installing ANT
*Note – If you are using the ANT plugin for Flash Builder you can skip this step.
First, you need to go and download Apache Ant [http://ant.apache.org/]. If your not currently familiar with Ant, check out this Post by Charles Newman. Once you have ANT, unzip and store it somewhere on your system.
Now that you have ANT stored on your computer, you need to add it to your class path. What this means is that once added you will be able to run the ‘ant’ command from anywhere on your system as if you we inside your-ant-install-dir/bin. Basically, this is a list of directories that your shell will look through when running a command. Now open terminal and trace your current $PATH variable.
echo $PATH /Applications/apache-ant/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Adobe Flash Builder 4.5/sdks/4.1.1/bin:/usr/local/git/bin:/usr/X11/bin
When you look at your version you won’t see ‘/Applications/apache-ant/bin:’. This is because you haven’t added it yet. To add to your PATH variable run this command.
This will add your new path to the end of the list. Be careful if you have installed the developer tools that come with OSX as they ship with a version of ANT. If this happens, the one defined first will take precedence. To change this, you can modify your command to prepend your new class variable to your path listing by modifying the command.
Check what version you are currently using this command.
which ant /Applications/apache-ant/bin/ant
Now you can run the ant command ant see some type of response.
ant Buildfile: build.xml does not exist! Build failed
This is good because it means everything is working correctly (we haven’t created a build yet).
Next, we need to modify a file that runs on startup, which will add this to our class path every time we reboot. To do so open .bash_profile with your favorite text editor. I use VI:
Now add the export command to the .bash_profile file.
Now close out of your text editor. If you reboot you will see that you can run ANT without having to add it again to your class path.
Step Two: Get external JAR dependencies
Now that we have ant, we need to get the exernal libraries that will allow us to use FTP & SSH (SFTP). Go get the following:
Now that we have these, we need to add them to our ANT lib directory. If we have downloaded ANT, just drag these to /your-ant-directory/lib/. If you are using the ANT plugin, you can add these through the preferences in the IDE.
Flash-builder>preferences>ant>runtime>global entries>runtime>classpath>global entries>global entries>add external jars
That’s all you need to do to set up your system. Now we need to build some scripts to FTP.
Here is an example of how to implement these new features from within ant. If you are behind a firewall be sure to use “passive” mode on FTP and “trust” mode on SFTP.