Using ANT with Flex Library Projects

| 3 Comments | No TrackBacks

In working on the ActionScript 3.0 Libraries, I needed a way to easily create .swc files, run unit tests, and generate documentation. My solution? ANT!

All of the ActionScript 3.0 Library projects on Google Code now have build scripts to make working and interacting with them easier. The projects have a "build" directory under the trunk with build.xml and build.properties. The build.xml does the heavy lifting, and the build.properties is where you can configure paths on your system such as the locations of compc.exe and asdoc.exe.

For an example, take a look at the XML Syndication build.xml and build.properties files.

The build script has 3 main targets.

The test target depends on the compileTests target. It invokes mxmlc to compile a simple Flex application to run unit tests for the library, and then opens up the test runner in the stand alone Flash Player so you can see if the tests are successful for not.

The lib target compiles all of the classes under the src directory into a .swc file, and places that in the bin directory. Note that the lib target factors in the necessary dependencies when building the library .swc file.

The docs target runs ASDoc against all of the classes under the src tree and places the resulting output in the docs directory.

By having an ANT script to work with Flex Library Projects, it makes managing the project much easier. If you open up the build.xml file in FlexBuilder, you can right click on a target name in the outline view, and select "Run As..." -> "Ant Build". Everything you need is right at your fingertips, and ANT makes it easy.

I encourage you to become familiar with ANT if you're a Flex coder. It's a powerful tool in the toolbox, and lets you do a lot of wonderful things. As I've mentioned before, I use ANT so much that it's become just another scripting language to me, similar to how other developers might use Python. I've even managed to show Ted the light, and he's a die-hard Pythoner!

Anyway, I wanted to mention this because it's something that has been useful to me. If you have a Flex Library Project that you're maintaining and you don't have a build script yet, this should be useful to you as well. Consider using the examples I've created as a base to get you started. You'll come to appreciate just how easy ANT makes things... and if you don't know ANT yet, it's not too late to start learning it!

No TrackBacks

TrackBack URL: http://www.darronschall.com/mt/mt-tb.cgi/138

3 Comments

  • Agreed, ant is invaluable. Should note that Adobe chose not to include ant in the standalone version of Flex Builder. Peter Elst gives a good writeup on how to enable it here: http://www.peterelst.com/blog/2006/09/03/flex-builder-2-ant-support/

     
  • Where is one of your example projects that uses Ant? I looked at the YouTube zip and didnt see any build files in there.

    thanks

     
  • Hi shawn,

    The .zip files on the Google Code projects pages haven't been updated because we haven't done enough yet to warrant a new release.

    Follow the links I made in the entry to the build.xml and build.properties files to get them, or do a checkout from the Google Code SVN repository for the project.

     

Leave a comment

Flex.org - The Directory for Flex

Archives