Flex Ant Tasks Incorporating a SWFObject Wrapper Template
I have had a weekend of playing around with Flex Ant Tasks and I still can’t believe that I have not submerged myself in this subject earlier. I have used Flex Ant related scripts in the past but never really dived in and had a good ol’ play in depth coding some up myself. There were a few reasons why I got my hands dirty with Flex Ant Tasks, heres two of them:
1) A more efficient method of altering the existing html-template wrapper i.e. index.template.html to use SWFObject (as does Gumbo) which didn’t involve me copying and pasting my source files into each Flex project manually each time. 2) Wanting to have a more structured build and release process for my project files in a multi developer environment.
The main tasks I wanted to achieve were:
- Run SWF builds (1) release (2) debug.
- SVN checkout of latest Flex SDK > templates > SWFObject.
- Generate wrappers using SWFObject (1) release (2) debug.
- Copy asset libraries into (1) release (2) debug.
- Running Flex Unit tests (not included in this script).
There were a few hurdles I came across some plain stupid, some plain obvious and some did admittedly require a good dig on the web to solve. Aspects I achieved included:
- Refactoring logic I had previously used to incorporate Macrodefs helping to maintain OOP (see Eric Feminella).
- Connecting to a SVN repository and retrieving the latest Adobe Flex SDK SWFObject source files for use as the html-template (see svnant).
- A silly issue I found being thrown with my Degrafa swc (Error: Could not resolve
to a component implementation) solved by the following (doh!):
1 2 3 4 5 6 7
. - Ensure in a project using the Flex 3 plugin in Eclipse that the SWFObject wrapper logic currently used in Gumbo is implemented i.e. uses the new SDK SWFObject template.
I have bundled all the tasks into one xml file (and all the properties into a separate file) for convenience but do not suggest that you run this whole script each build due to it retrieving the latest SWFObject directory from Adobe’s Flex svn, this is obviously something you only want to run once (?when you first create your project).
I totally recommend reading Advanced Ant for Adobe Flex Projects, Using Flex Ant Tasks and how-to-build-ant-scripts-for-flex as they served as a fantastic basis to me getting things into a logical order. And finally it goes without saying, anything ANT related means you gotta check out The Crumb!