January 2007 Archives

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!

Over the past few weeks, we've been silently moving the Open Source ActionScript 3.0 Libraries from Adobe Labs to Google Code. I'm happy to announce that we put the finishing touches on everything last night, and we're now open for business.

As Mike Chambers mentioned, the reason for the move is because Google Code offers a better infrastructure for the projects. We now have a mailing list, wiki, and issue tracker for each of the individual libraries. More importantly, other developers will find it easier to contribute. For example, Owen van Dijk recently added Uploading support into the Flickr API.

The projects now on Google Code are:

I'm very excited about this move. I hope it can breath new life into the libraries as more people get involved and more transparency is introduced. If you are interested in contributing to any of the projects (either writing code, doing testing, writing documentation on the wikis), sign up on the appropriate project mailing list and offer to help. Also, feel free to log any bugs or issues you may run into on the issue trackers (but search before you post, so we can avoid duplicates!).

Thanks to Mike, Mike, and Charles for helping to make this move a success!

This is just a quick note to mention that my Animate Color Effect for Flex 2 has been updated for the 2.0.1 update of Flex 2.

The only change was modifying the effect to reflect the updated Effects framework. In Flex 2.0.1, EffectInstance is now IEffectInstance.

The demo of the effect has been updated, as well as the example code. Right click in the .swf after it loads to view the source and download the code in .zip file. As before, this is released under the MIT License.

Tags:

Flex.org - The Directory for Flex

Archives