Manifest Ant scripts for Flex Builder 2

So leading on from my post on creating config and manifest files for your Flex Projects, here are the Ant and Shell scripts to automate the whole process.

As I mentioned in my previous post, curerntly these are targeted at Mac OS X and *nix operating systems (because I use find, grep and sed to mangle the directory output). I’m working on a Windows version but it may take some time. Anyway if you want to use them just head over to the downloads page and you can grab them there (alternatively just click here).

As for installation, this is pretty easy (I’m not going to explain how to install Ant etc if you need help doing that read Peter Elst’s guide here)

So now you’ve downloaded them what do you do with them?

I’m going to go through setting the scripts up on a Mac (OS X 10.4.x) using Flex Builder 2+. For those of you using the Flex SDK or some other tool you can follow this article but you’ll need to amend it where it details integration with Ant. As you will likely have that installed and configured in a different manner.

  1. OK so first things first create a folder in your Documents folder and call it Scripts, inside of this create another folder calling this Flex. Inside of this folder copy the three files GenerateManifest.sh, GenerateConfig.sh and build.xml that you extracted from the zip.
  2. Next open up Flex Builder and in the project you wish to use the Ant scripts with create a folder in the root of the project called build. Once you have created this folder you will need to import the build.xml file into this directory.Flex Builder Import menu
  3. To do this right click on the build folder and select Import from the context menu. (see image opposite)
  4. In the dialog that opens select the entry called General and expand it so you can select the sub entry File System. Now click Next.
  5. On this screen you can browse to a folder on your system. So browse to the folder we copied our scripts to ~/Documents/Scripts/Flex (~ is the shortcut for /Users/YourName).
  6. Once you have that folder selected click Choose and you will be returned to the initial dialog (don’t worry if an warning comes up at the top of the panel).
  7. Select the folder in the left hand pane (it should read Flex) and all the files that are inside it will populate the right hand pane if you just check the checkbox nothing will be displayed so just click on the folder name and ignore the checkbox altogether.Ant Panel
  8. Select the build.xml checkbox and deselect anything else within this folder that may have been selected by accident.
  9. Click Finish.
  10. The build.xml file should now be in your build folder inside the root of yo project.
  11. Now open the Ant panel in Flex Builder (if you haven’t updated Flex Builder so that Ant is installed yet you need to this first – see the link to Peter Elst’s article above).
  12. With The Ant panel open click and drag the build.xml file on to the Ant panel and release it. If do it correctly it will appear in the panel and you can expand it to display the tasks that can be accessed through this particular script. The one that is highlighted in blue is the default and will run all the related sub tasks that are associated with it if executed.

So that’s the script imported. We’ll leave it there for the moment and come back to it once we have sorted out the other two scripts (GenerateManifest.sh and GenerateConfig.sh).

Now these files are in your user space and they need to be interacted with by Flex Builder so you’ll need to make a couple of alternations to these files to make sure that they are accessible to it. Firstly you need to make sure that the can be executed (by default files created cannot be executed so you need to set the flag that allows this).

  1. We need the Terminal for this so open it up and set the location to the Flex folder. To do this type the following into the terminal window: cd ~/Documents/Scripts/Flex/ With this done we are now inside the folder that holds our scripts so we can now “operate” on them.
  2. So we need to make them executable and to do this we need to apply some commands via the terminal – don’t worry if you’ve never used the terminal before, just follow my lead and you’ll be fine.
  3. In the terminal type the following: chmod 755 Generate* This just makes sure that the files are executable so that they can actually be run by the Ant script (or the terminal if you supply the correct parameters).

Well now we have our scripts in place we need to hop back to our Ant script and make a few alterations to it. So switch back to Flex Builder and double click on the build.xml file and it should open in the main window ready for editing. Now I’ve tried to keep this as simple as possible so you don’t have to change too much. So with that in mind we are going to enter the following parameters into the file:

  • The path to our scripts (if you’ve put them somewhere other than the directories detailed within this article)
  • The name of our Flex default project file (we’ll see why we need to do this in a moment)

Our folder structure and our newly created config and manifest files
That’s all we need to do so read on and we’ll add these last few bits. Then we should be ready to do a test. Look for the entry in the build.xml file that begins with <property name=”ManifestScriptPath”… (it should be on line 38). If you have placed the scripts GenerateConfig and GenerateManifest in an alternative directorty to those listed update them to reflect this.

With that done we have one more thing to do – change the project name to that of your default application file name. The property that is responsible for this can be found on line 56 and looks like this: <property name=”ProjectFilePrefix” value=”MyProject” />. Change the value to that of your default application file and save the build.xml file.

There are a host of other parameters you can set within the build.xml file, I’m not going to go over those here as they are pretty self explanatory but just so you are aware you can set flags for things like the default background color, whether the generated ActionScript should be kept etc etc.

Hopefully this will provide some use for those who like to have the ability to configure a project simply and efficiently from directly within Flex Builder itself as opposed to setting the flag values in the properties settings – I did it as it saves me time in the long run.

This script is by no means complete yet I have some beta functionality that I am just testing and once that is stable I will update this package and release it.

Things I have on my radar are:

  • Add in the services parameter (this I have working but I just need to tidy up the logic in the main script)
  • Include my ASDocs tasks
  • Include a few more of the compiler parameters
  • Work out how to get the code hinting to work if you use a namespace in this manner as opposed to the xxx.* style namesapces
  • Windows version

If you have any questions feel free to leave a comment and I’ll get back to you with a response :D

Mike Jones


  1. Hey this is cool and definitely useful for us. Although i have noticed a lot of problems with the fb ide 2 and 3 when pointing to custom config and manifest files eg, code-completion not working.. Have you found any workarounds for this?



  2. Hi Bjorn, glad it helps. As to the code completion issue, I’m still looking into it. This solution is orientated to compiler directives and therefore breaks the code complete. I’m gonna ping off a few mails to some friends at Adobe and see if they can provide a solution (if there is one).

    I’ll post as soon as I have an answer


  3. Hi,

    I have a similar situation and needed to generate manifest files for the command-line compc. I found that Flex Builder keeps similar information in a file called .flexLibProperties — this is slightly better because there are some classes that we want to exclude from the compiled .swc, whereas your script gets everything under the target directory. I posted to the Ant user mailing list, and Jan Materne provided an Ant xslt task that would transform the .flexLibProperties file into a manifest.xml . For users who have Flex Builder, they may find this easier to use… See this thread:

    FWIW, the -s option for ‘find’ doesn’t seem to be used on linux. Also, the last sed substitution would do this to the line:
    id=”ClassA” class=”long.package.name.ClassA”>
    I’m guessing there are some subtle differences in ‘find’ and ‘sed’ between OSX and linux…

  4. hi,

    did u manage to solve somehow code completion issue?


Comments are closed.