Give us a call 203-379-0773
Check out our Angular Book Series.

How to Build Apache Flex 4.8 from the Source

I have exciting news today. Since the last Flextras newsletter, the Apache Flex team has released Apache Flex 4.8. This is the first Flex release under Apache, and it feels good that we're finally here. Apache Flex 4.8 is a parity release to Adobe Flex 4.6. That means you won't find any new features or bug fixes, but it was primary there for the Apache Flex team to get an understanding of how things work in the Apache world; and how to get a release out the door.

Formally a release under the Apache Flex project can only be source code. Binary distributions are provided as a convenience, but not required. Today I'm going to show you how to get the source out of SVN, and then how to build Apache Flex. I've done all these steps on Windows 7; however they should be similar on other operating systems.

Get the Source

The first thing you'll need to do is get the source code. You can do that from the Apache Flex Download page. Or you can use your favorite SVN Client to check out of the trunk.

For the purposes of this sample, I used SmartSVN to download the current trunk branch.

Install the Prerequisites

In the trunk directory you'll find RELEASE-NOTES and a README file. I suggest you open them in your favorite text editor and read them. Read the README twice because that has the bulk of the details on how to build Apache Flex. The first step is to install the required prerequisites. As a developer, you'll probably already have a lot of these installed, but I'll go through the complete list just in case:
  • Java SDK: To build Apache Flex, you'll need to install Java SDK 5 or 6. Java 7 is not supported at this time. I downloaded Java SDK 5 from the Oracle site, but had to create an account to do so. Honestly I was surprised this wasn't already on my machine.
  • Apache ANT: ANT is a build automation tool. You can download binary distributions from the Apache ANT web site. ANT does not have a formal install process, so I just unzipped the binary and was good to go. An ANT version number is not specified, but I installed ANT 1.8.4
  • Cygwin : You can get a Cygwin installer from the Cygwin web site. I don't fully understand what it is used for, after installing it I never had to reference it directly again. It is worth noting that the install process strongly recommends against having a space in the name of Cygwin path, which means I decided not to put it in the standard "Program Files" directory. The install process for Cygwin felt like a package manager, similar to installing the Android SDK.
    I chose to use all defaults in the install process.
  • Adobe AIR Integration Kit: Due to various licensing and IP issues, the Apache Foundation isn't allowed to distribute everything that is needed. This item and the next four are Adobe specific dependencies you'll have to get yourself. The Adobe AIR Integration kit link is easily found in the read me. A Mac version is here.
  • Adobe Flash Player Content Debugger: The current release of the Flex SDK is written for Flash Player 11.1, and you'll need the 11.1 content debugger. The read me will point you to here to get the latest. Unfortunately, the latest is not 11.1. Click the "Older Versions of Adobe Flash Player" link, and then download the 11.1 version. The next step confused me a bit. You'll want to use the Flash Player debugger included in that zip. Put the file (flashplayer11_1r102_63_win_debug_32bit.exe) in a directory named 11.1 .
  • Adobe Pixel Bender Toolkit: The Adobe Pixel Bender Toolkit can be used from here on a PC or here on a Mac. On my PC, I just unzipped the zip, and ran the set-up executable inside the unzipped directory.
  • Adobe Flash Player: You'll need the playerglobal.swc for the 11.1 version of the Flash Player. A direct download is included from the playerglobal.swc . This file must be put in a 11.1 directory and renamed to playerglobal.swc.
  • Adobe Extension Manager CS5: The Adobe Extension Manager is only needed if you are going to creating, or testing changes to the flash-integration SWC. You can download the extension manager from here. Installation is a matter of opening the zip file and running the set-up file inside the directory. The Mac version can be found here.

Take some time to run through the pre-requisites and make sure everything is installed and ready. Next, you'll have to set up some environment variables.

Setting Environment Variables

This section will explain how to set the environment variables to point to the appropriate directory locations. There are two new environment variables you'll have to create as Windows environment variables, and the rest can be set up in a properties file. I'll cover both separately.

If you've never had to do it before, I found this great tutorial for setting up Environment variables on Windows 7. There are two environment variables you have to set up:

  • JAVA_HOME: JAVA_HOME should point to the root install directory of you Java SDK. For me, it was this: "C:\Program Files (x86)\Java\jdk1.5.0_22\" .
  • ANT_HOME: The ANT_HOME variable points to the directory where you unzipped Apache ANT. For me this was "C:\Program Files (x86)\Apache Software Foundation\apache-ant-1.8.4 " . There is no custom install process for Apache ANT, so your directory location may be different.

While you're setting up environment variables, be sure to update your path. In the path variable, you'll want to add the bin directory for the ANT_HOME and JAVA_HOME. Add this at the end of your path statement.


This may be a good time to reboot your machine as an easy way to get the new environment variables to take effect.

The rest of the environment variables you need to specify are not Windows environment variables, but rather values you need to set in a config file. Copy the file, in your trunk directory, to and then open it in a text editor. This file is fairly well documented, so I suggest reading through it to understand all the setting all the relevant environment variables. When setting the path variables, on Windows, I forgot to double escape my '\' inside the file. Be sure you don't make the same mistake. These are the variables:

  • AIR_HOME: The AIR_HOME variable points to the directory where you unzipped the Adobe AIR Integration Kit. On my machine it was something like "C:\\Projects\\ApacheFlex\\Development\\ Dependencies\\AIRIntegrationKit\\AdobeAIRSDK"
  • FLASHPLAYER_DEBUGGER : The Flash Player Debugger value points to the location of the content debugger. I specified this as the full path to the debugging player file. "C:\\Projects\\ApacheFlex\\Development\\ Dependencies\\ContentDebugger\\11.1\\flashplayer11_1r102_63_win_debug_32bit.exe"
  • PLAYERGLOBAL_HOME : The PLAYERGLOBAL_HOME variable points to root location of your playerglobal.swc directory. Inside this directory, you'll have the version number, in our case 11.1, and inside that the file named playerglobal.swc. My location was "C:\\Projects\\ApacheFlex\\Development\\ Dependencies\\PlayerGlobal"
  • PIXELBENDER_HOME : The PIXELBENDER_HOME value should point to the install directory of the Pixel Bender toolkit. My location was "C:\\Program Files (x86)\\Adobe\\Adobe Utilities - CS5.5\\Pixel Bender Toolkit 2.6"
  • ADOBE_EXTENSION_MANAGER: The ADOBE_EXTENSION_MANAGER value points to the exe behind Adobe's CS Extension Manager. My location was "C:\\Program Files (x86)\\Adobe\\Adobe Extension Manager CS5\\Adobe Extension Manager CS5.exe"

Once you have the environment variables all set up, you're prepared to start building.

Running the Build

It's time to run an ant script and build Apache Flex from the source code. Open up a command prompt and point it to you're the directory you checked out. In Windows 7 you can select a directory in Windows Explorer, press the shift key and the right mouse Button then the value "open command window here" will be available from the context menu. Select it to open the command window. Once at the command window, type

Ant main

If everything is good, you should start building. The build is not completely automatic. First, it'll ask you to accept the Mozilla Public License in order to download and use the Adobe Text Layout Framework.

Press Y to accept and the build will continue. Then you'll be asked to accept the same license in order to use Adobe's Open Source Media Framework.

Press Y to accept and the build will continue. The next thing you must accept relates to font support; and makes use of some jars from the Adobe Flex SDK.

Review, and accept the license agreement as appropriate. The build should complete after that. The full build process will probably take between 5 and 10 minutes depending on how long it takes to download some various remote parts from relevant servers.

Congratulations, you've just built Apache Flex.

Using Apache Flex with Flash Builder

Now that you've built it, you'll probably want to use Apache Flex with Flash Builder, IntelliJ or some other IDE in order to create your applications. My primary IDE is Flash Builder, so I'll talk a little about that. Flash Builder expects certain files to be in certain places; and in our default build those files are not in the places they need to be.

There are a few options to solve this dilemma. One is to use the IDE Packager application. It is an AIR App created by an Apache Flex Contributor to do the heavy work for us. This packager is in beta and not part of the official release, but I've heard many positive things about using it. The new option is to use this batch file which will merge an Adobe Flex 4.6 installation with Apache Flex 4.8 in order to create a Flash Builder compatible build. A final option is to move files around manually. Documentation on what needs to be placed where is found in the IDE directory of the trunk.

I'm not going to go over any of these items in complete detail in this newsletter, as I'm already a bit long.

Final Thoughts

For future Apache Flex releases, I'd love to see it become as easy to use as adding a SWC into a library path for an ActionScript project. Unfortunately, we're not there yet. But, the Apache Flex 4.8 release is a strong start to Flex's continued relevance as part of the Apache Foundation.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)