Compile Flex 3 Application From Command Line
Monday, June 01 2009 - flex-3
Last week I embarked on a quest to get our application(s) to compile via Jet Brains Team City. In order to do that, the applications must be compiled from command-line. Technically, I could have installed Flex 3 Builder on the build machine, but I don’t consider that a real option.
I took an inventory of my other options: ANT, NANT, Batch file, etc., and decided that while ANT is probably the technically correct approach, it wasn’t something I wanted to get into. I am fairly proficient with NANT so NANT + Command-line was the obvious choice.
The 1st step was getting the build to work via command-line. In order to do that I needed to get a command-line representation of the project so I know what to compile. Flex 3 Builder gives you this ability via the project properties:
Your Project->Properties->Flex Compiler: In the Additional Compiler Options text box you can put the –dump-config value with the name of the file you want:
When I build the above project I get a file: plannerclient-config.xml
The next step is to call the compiler and pass it the config file. In my case, I was not using modules so the only compiler I need is mxmlc.exe. This file is in the Flex 3 SDK directory. Make sure you set the Flex 3 \ bin directory in your path.
To compile my project I ran:
mxmlc -load-config plannerclient-config.xml myproject.mxml -output bin/myproject.swf
Unfortunately this didn’t work. The compiler threw multiple errors for various issues; most due to inability to resolve class references. I spent considerable amount of time trying to resolve the reference issues and finally decided it wasn’t worth it.
David Burger posted a very similar method to what I’ve detailed above, but instead of using the –dump-config option, you take the default flex-config.xml and modify it with the correct names and paths for your project. Then pass this config file into the command-line compiler:
- copy the flex-config.xml from the flex SDK's frameworks directory into the root of your project
- edit the flex-config.xml in your project, prepending ${flexlib}/ to all the libs/ paths and before the path references to manifest.xml and locale/
- edit the flex-config.xml in your project, uncommenting the source-path element and setting its path-element element to src
Once I setup my project, which was simply copying the appropriate values from my plannerclient-config.xml to my copy of flex-config.xml the build worked.
Hooking it up to Team City and triggering the build on a SVN check-in only took a few minutes. Now on each check-in I get two builds: one with framework RSL’s and one without.
