Archive for the 'Uncategorized' Category


Moving files with Ant

Laziness is a virtue. At least the kind of laziness that makes you go “How do I deliver top quality with the least amount of work” as opposed to “I can’t be bothered and I don’t care” laziness

Ant is created by the former type of lazy programmer. For those unfamiliar with it, Ant script lets you script almost anything in Eclipse (and by extension, Flex builder). It can do complex stuff like updating from subversion, compiling etc. Or very simple stuff – which is what I mostly use it for.

I develop on my local drive and need to move the complied release version swf from my computer to our staging/test server. Doing this manually is boring, opening folders and all that. A simple Ant script does the job for me:

<?xml version="1.0" encoding="UTF-8"?>
<project name="movefile" default="main">
    <target name="main" depends="move" description="Move release swf to test-server"/>
    <target name="move">
        <move file="bin-release/myproject.swf" todir="W:\myProjectDirectory"/>

As you can see, it’s a ridiculously simple xml file – just change the file name and destination directory. Right-click and choose Run as: Ant build runs it. After the first run, it will be added to the Run-as menu in the icon bar – looks like a play button with a red toolbox. Which means I can lazily move files with one click.

I use “move” instead of “copy” to ensure that I remember to build a release version every time – if the script is run and there is no file in the release folder, I get an error.

If you use the standalone version of Flex builder, you need to install Ant – see this handy tutorial.