Including Assets Files with ANT
Building off of the last few posts, we are continuing to build our one big ANT file that will build your amazing Enterprise Application.
As you are building your application you probably also have a set of assets that aren’t embedded in your final SWF file. Flex/Flash Builder automatically adds this file into your bin and release files, but we need our build script to do the same. Achieving this trick is pretty simple.
Our new target to copy these nonembedded assets is a simple step if we follow some guidelines. By putting our assets into one folder system rather than throughout our application’s packages we can quickly copy the entire folder right over.
<echo>Deleting Deploy Assets Directory...</echo>
<delete dir="${DeployAssets.dir}" failOnError="false" includeEmptyDirs="true" />
<echo>Deleted Deploy Assets Directory</echo>
<echo>Creating Assets Folder</echo>
<mkdir dir="${DeployAssets.dir}" />
<echo>Created Assets Folder</echo>
<echo>Copy Nonembedded Resources To Deploy</echo>
<copy todir="${DeployAssets.dir}" includeemptydirs="false" overwrite="true">
<fileset dir="${Assets.dir}" />
</copy>
<echo>Copied Nonembedded Resources To Deploy</echo>
</target>
This code clears out any old folders and copies the assets from your assets folder to your deploy directory. To make all this complete we just need to add a few lines into our build.properties.
Assets.dir=${Src.dir}/assets
#Assets
DeployAssets.dir=${Deploy.dir}/assets
If you have reading these posts in order, you can now build a project, build a library, build your custom and default html wrappers, and now include your non-embedded assets. I think we are doing pretty good so far.





Hi,
Have you found any way of speeding up your builds with Ant? I spent a good chunk of time learning it, then trying to find a way of speeding it up because it was far too slow to use on a regular basis (vs Flex builder or FDT). As far as I am aware this is because of a combination of 2 factors – it doesn’t use incremental complilation, but compiles in one big hit, and the eclipse based IDEs use compilation code written at a much lower level and therefore much faster. Would be good to know if you found some rocket fuel to feed it.
@pedr Great question. When I have set up ANT projects they are mainly to create a release quality build as part of a continuous integration stack. So my files mainly run at the night after commits have been made, etc. That being said, I haven’t worked on tons of performance tuning on my ANT scripts as much as making them easy for a system admin to be able to run and understand.
When it comes to incremental compilation, I did attempt to get that working and had issues, so I didn’t continue down that path. I felt it was for the best as I usually wanted to build a completely new/fresh build. I agree that Adobe has but some secret sauce into their IDE (and FDT) to continue to improve the build process.
Are you using ANT builds to do daily iterative work?
I started out doing that, but my impatience wouldn’t stand for all the thumb twiddling waiting for Ant to build. I’ve avoided using it only for release builds as it seems like having two parallel builds is a surefire way to introduce strange bugs – can I really use Ant for a release build and trust it will compile exactly as eclipse, or might I introduce problems through discrepancies? What would be perfect is if Fb could parse ant files and use its own secret sauce to keep them fast. That way we would get the best of both worlds – portable builds and speed.
I would always say that you should test your release builds either way to ensure that you have the quality build you are looking for. I would highly recommend building into your ANT stack both Unit Testing and Automation Testing. I have a few more blog posts in the queue that is addressing these exact concerns. Makes it a little easier for you to run a script walk away, and come back in a few minutes to having everything run and checked for you.
Nice. I will look forward to them. You’ve got me playing with Ant again. Spent the afternoon tidying up all my old build files. Found something interesting in FDT – You can specify pre and post compile Ant scripts, so I’m wondering if I can do everything but the compilation in ant – moving files, html template, tests etc, but let FDT handle the compile.
I agree, every few months I dust off the ANT skills and get knee deep. Then go back to coding as usual.
You mentioned above that you use FDT. I’m having a problem getting flextasks to work alongside fdt’s own targets. It seems that fdt’s targets (fdt.browse etc) will only work if running in the same JRE, but flextasks will only run if in a separate one (JRE changed through run/external tools/external tools config…/JRE). Have you ever run into this? Just upgraded to FDT 3.5 so might be a new bug.
[...] This post was mentioned on Twitter by Jonathan Campos, Bruno Fonzi. Bruno Fonzi said: @jonbcampos: @Michael_Plank @TheFlashBum @ultraky are the #ANT #FDT gurus I know on twitter world http://bit.ly/c98jJa (they might help!) [...]
@pedr I’ve contacted some of the guys at FDT and haven’t been able to get anything solid back. Feel free to ping them and ask. They are usually very open and accommodating. I have had lots of positive conversations with the FDT guys.
http://fdt.powerflasher.com/blog/
[...] Wrapper with ANT January 20th, 2010 – Building a Custom HTML Wrapper with ANT January 21st, 2010 – Including Assets Files with ANT January 26th, 2010 – Building a Library and Application with ANT January 28th, 2010 – Building [...]