Fuel ANT Tasks

At Fuel Industries our projects always start with a FLA, but we use FDT for all of our coding. We wanted to have a way that we could publish our projects from FDT as well as run daily automatic builds. This is easy when working with Flex because Flex has a command line compiler, but Flash doesn’t. So we wrote custom ANT tasks in Java that will allow us to publish fla’s in multiple ways.

Here are a few examples of some of the things you can do.

First you can simply compile fla’s

<target name="fla_publish">
	<flash>
		<fla file="${src}/redsquare.fla" build="publish"/>
		<fla file="${src}/bluesquare.fla" build="export" swf="${src}/bluesquare.swf"/>
		<fla file="${src}/greensquare.fla" build="test"/>
	</flash>
</target>

The fla task can take multiple different types of values for the build parameter – publish, test, and export.
publish will simply publish the file at the current settings set for the fla.
test will compile and run the swf in the Flash IDE. This is like hitting cmd-enter/ctrl-enter
export will export the swf. In order to use this mode you must specify a output swf file.

You can also publish and test Flash CS3 Flp files

<target name="flp_publish">
	<flash>
	     <flp file="${src}/fuelanttask.flp" build="publish"/>
	</flash>
</target>

If set the build mode to “test” it will look for the flp project default file and compile that project last and test the default file.
The nice thing about using the flp task is that if one of your files has a compile error, it will stop the build process and alert you of the error. This is different then the IDE as it just keeps compile the project and you won’t see if one of your files compiled incorrectly.

We have also created a task called buildnumbercommand. This task gets the local SVN revision number and inserts it into a BuildNumber.as file. This way we have the build number accessible in ActionScript and we are able to display it automatically in our files. For instance we place ours in the right click menu so our clients can see what version of the build they are looking at.

<target name="version">
	<buildnumbercommand path="${src}" />
</target>

The path parameter is the directory in which the BuildNumber.as file is located. Below is an example of BuildNumber.as

package
{
	public class BuildNumber 
	{
		public static const BUILD_NUMBER : String = "1";
	}
}

Here are some of the other parameters for the Tasks

flash task

path – This is needed on Windows only. This is the path to your Flash IDE executable and is defaulted to the default install location for CS3 and CS4. C:\Program Files\Adobe\Adobe Flash CS3\Flash.exe and C:\Program Files\Adobe\Adobe Flash CS4\Flash.exe. If you have the Flash IDE installed in these locations you can omit this parameter.

version – accepts either “CS3″ or “CS4″. The default is “CS3″. This is used to determine which IDE to compile your files in. “CS3″ is the default and can be omitted if you want to use CS3.

deleteaso – true | false will delete your aso files before compiling any files. The default is false.

closeDocs – true | false will close your fla after it’s compiled. The default is false. This is ignored when compiling a flp project and will always close it afterwards.

quit – true | false will close the Flash IDE after all the files have been compiled.

verbose – true | false has some more output messages during compilation.

fla task

file – the path to your fla file

build – valid values are “export”, “publish”, “test”. The default is “publish”.
publish will simply publish the file at the current settings set for the fla.
test will compile and run the swf in the Flash IDE. This is like hitting cmd-enter/ctrl-enter
export will export the swf. In order to use this mode you must specify a output swf file.

swf – the file path to a swf to be compiled. This is only needed when the build parameter is set to “export” and will be ignored otherwise.

flp task

file – the path to your flp file

build – valid values are “export”, “publish”, “test”. The default is “publish”.
If set the build mode to “test” it will look for the flp project default file and compile that project last and test the default file.

UPDATE : the ANT tasks have been put up on Google code. The source, examples, documentation, and the compiled jar can be found there

http://code.google.com/p/fuelanttasks/

This is a video of me showing how to use them at Flash On The Beach during the speaker throwdown

FOTB09 – Jam Throwdown – Julian Dolce from John Davey on Vimeo.

Continue reading » · Written on: 09-23-09 · 23 Comments »

23 Responses to “Fuel ANT Tasks”

  1. Tweets that mention deleteaso » Fuel ANT Tasks -- Topsy.com wrote:

    [...] This post was mentioned on Twitter by HowDo.us. HowDo.us said: Fuel ANT Tasks: At Fuel Industries our projects always start with a FLA, but we use FDT for all of our coding. W.. http://bit.ly/MEq3R [...]

    September 23rd, 2009 at 5:44 am
  2. Simen Brekken wrote:

    Any plans to release the source for these tasks? We usually use constants (-define=CONFIG::version,’123}’) to store the build number instead of a file like BuildNumber.as but the current build system requires svnversion which isn’t optional.

    September 23rd, 2009 at 8:09 am
  3. Simen Brekken wrote:

    Any plans to release the source for these tasks? We usually use constants (-define=CONFIG::version,’123}’) to store the build number instead of a file like BuildNumber.as but the current build system requires svnversion which isn’t optimal.

    September 23rd, 2009 at 8:10 am
  4. julian wrote:

    There are plans to release the source code. I just need to get a few things sorted out with some people at the office before we do. I will update here when we do.

    September 23rd, 2009 at 2:08 pm
  5. FOTB 2009 Day 3 | The random utterances of David Arno wrote:

    [...] next session was by Julian Dolce and was much more up my “Nerd Street”. It covered an ANT plugin that lets a developer working within FlexBuilder generate and test SWF’s from FL…. The caveat – I think – is the fact that it was achieved by driving the Flash authoring [...]

    September 25th, 2009 at 8:33 am
  6. » Day Three Marc Hibbins wrote:

    [...] to do this on a Mac, and Flex can do this anyway but Flash usually can’t. Good news is, it’s all available on his website and it can handle straightforward publishing, debugging, FLP files, intelligent error handling and [...]

    September 27th, 2009 at 1:53 pm
  7. Gavin wrote:

    I saw you demo this in the Jam session @ FOTB – looked awesome so I have tried to use it on my MAC (with CS4) but i can’t get it to work. I have downloaded the sample project and am just playing with that, when I run an ANT task a jsfl appears in the /fuelanttasks/ folder but nothing further happens….if i run the jsfl directly into flash it all behaves itself…is there something I need to set up on my machine to get this working?

    September 28th, 2009 at 11:36 am
  8. julian wrote:

    @Gavin
    Try putting version=”CS4″ in the Flash Task. Have a look at the brief documentation about that in the post. Currently since we use CS3 it defaults to that version. So behind the scenes it’s saying “tell Adobe Flash CS3″ to launch the jsfl file. And if you don’t have it installed it will fail. Let me know if that works out for you.

    September 28th, 2009 at 4:50 pm
  9. Adam Cousins flash portfolio – home of BADADAM music » Blog Archive » On the Beach… (part 3) wrote:

    [...] can us ANT in Eclipse to publish several FLA’s in one go. There is more information on this here. Some of the reasons for wishing to achieve this for Julian was so his company could publish their [...]

    September 29th, 2009 at 11:53 am
  10. Gavin wrote:

    Julian, I still cannot get it to work, have I included the version in the correct place?

    etc..

    The output in FDT says:
    Buildfile: /Users/gavinjackson/PROJECTS/IPOS_WorkingCopy/fla/build.xml
    fla_publish:

    BUILD FAILED
    /Users/gavinjackson/PROJECTS/IPOS_WorkingCopy/fla/build.xml:16: null

    Total time: 209 milliseconds

    October 2nd, 2009 at 8:52 am
  11. julian wrote:

    @Gavin
    Try the new version that is up on google code.
    http://code.google.com/p/fuelanttasks/

    October 3rd, 2009 at 10:00 pm
  12. Flashbordon wrote:

    @Gavin

    I had the same error. In my case it was because the task couldn’t find the .fla file i wanted to publish. I had written instead of

    Now it works like a charm… Nice set of tasks.

    October 8th, 2009 at 5:01 am
  13. Nils wrote:

    I’m trying to get the to work. Eventually, I’m getting this output:

    [buildnumbercommand] CreateProcess: svnversion -n error=2

    I’ve create a BuildNumber.as file in the src folder, is there anything else I need to do? Perhaps install svnversion?

    I’m running this on Windows Vista.

    Thanks!

    October 12th, 2009 at 7:27 pm
  14. julian wrote:

    @Nils

    If you just want to just use the compiling features of the tasks then you don’t have to worry about the buildnumbercommand.

    But if you want to use the buildnumber command you need to make sure that you have the svn binaries installed on your machine.

    Try installing the command line tool from here

    http://www.sliksvn.com/en/download

    Hope that helps.

    October 12th, 2009 at 7:36 pm
  15. Nils wrote:

    Thanks Julian. I’m actually only interested in the buildcommand, not the compilers. Saw your presentation at FOTB, hence the inspiration..

    I’ve already got TortoiseSVN, can you see any way to integrate with that instead?

    Thanks for the link, I’ll install svn and will see what happens.

    October 14th, 2009 at 6:03 am
  16. Karl Freeman wrote:

    This has been a lifesaver on a recent project I’m working on, must of saved at least half an hour a day. Thanks!!

    October 18th, 2009 at 5:15 pm
  17. Sine wrote:

    Is there any way I can use Ant succesfully to publish a Flash CS3 .fla to flash Player 10 (… I have replaced the playerglobal .swc to target 10 – and that sorta works when I publish out of Flash CS3, in that I can publish to 10, and most .fla’s will run ok – but the Vector class doesn’t seem to work… nor does SliderEvent, it seems.)

    Here’s hoping…

    November 26th, 2009 at 6:50 pm
  18. Mark Weaver wrote:

    This fills a HUGE gap in the Flash workflow! Thanks very much for making this available!

    December 2nd, 2009 at 1:50 pm
  19. Matt Przybylski wrote:

    Julian,
    This is a really useful set of tools. I was wondering if there was any plans on adding support for CS5? I tried running it with CS5 but obviously it’s not working.

    Also, is there any possibility of giving focus to the Flash IDE/SWF that gets compiled when the ant task runs? From my tests, I saw the output in my console in FDT but had to manually alt+tab over to Flash IDE to see the compiled SWF.

    Thanks for your work.

    Matt

    May 13th, 2010 at 1:27 am
  20. Jody brewster wrote:

    Glad to see someone using the ant task concept, btw I’ve got some other stuff I’ve been working on I may post soon. Been really busy lately. Love what you all have done with the code though!!

    June 6th, 2010 at 12:57 am
  21. Enhance your FDT setup even further with Eclipse plugins & Ant scripts wrote:

    [...] Fuel Ant Tasks After seeing Julian Dolce’s FOTB Jam Throwdown last year I’ve been using his Fuel Ant Tasks whenever I’ve needed to utilize the Flash IDE in any of my projects. The Ant script file is easy to set up and guaranteed will save you time with its ability to publish out whole folders of flas in the background while you carry on with stuff. So if your ever in painful station of having multiple fla dependencies with you project, this should be a lifesaver. [...]

    August 4th, 2010 at 5:06 pm
  22. Kudo wrote:

    Love this. I would also vote for CS5 support.

    The other thing which would be very useful is the ability to open (or refresh and give focus to) a specified HTML page once the publishing is complete. Often I need to preview the Flash in the browser, since it relies on flashvars or ExternalInterface etc.

    Thanks, great work.

    August 27th, 2010 at 5:46 am
  23. Shane wrote:

    Yes, it would be great if it could work with Flash CS5!!

    September 29th, 2010 at 11:58 pm

Leave a Reply