Flash Builder command line build

Flash Builder provides the Ant task <fb.exportReleaseBuild>. Use this task to implement command line builds that synchronize a developer’s individual build settings with the nightly build. Alternatively, you can use the <mxmlc> task in custom scripts for nightly builds.

<fb.exportReleaseBuild> task

Using the <fb.exportReleaseBuild> task ensures that the nightly build’s settings exactly match the settings used by developers during their daily work.

For example, if a developer changes the library path of a Flex project, the new library path is written to the Flash Builder project. When the nightly build machine runs <fb.exportReleaseBuild>, that task loads the Flash Builder project and all of its settings.

Another advantage of using <fb.exportReleaseBuild> is that it automatically takes care of additional “housekeeping” tasks normally included in a Flash Builder build, such as:
  • Automatically compile associated library projects

  • Copy assets such as JPEGs, and so on, into the output directory

  • Copy the HTML template, including macro substitution based on the compilation results (such as width and height)

Note: The <fb.exportReleaseBuild> task requires you to install Flash Builder on the nightly build machine.

<mxmlc> task

If you write a custom script that uses the <mxmlc> task (for example, an Ant script), then you do not need to install Flash Builder on the build machine. However, the build machine is required to have the Flex SDK available. Thus, the build machine can be on a Linux platform.

However, the disadvantage of this approach is that you have two sets of build settings to synchronize: One in Flash Builder, used by developers during their daily work, and another on your nightly build machine.

<fb.exportReleaseBuild> usage

  1. Install Flash Builder on a build machine.

  2. Write build.xml with fb.exportReleaseBuild as a target. For example:

    <?xml version="1.0"?> 
    <project default="main"> 
        <target name="main"> 
            <fb.exportReleaseBuild project="MyProject" /> 
        </target> 
    </project>

    build.xml specifies to run a command line build of your Flex project, using the settings saved in your project files. See Parameters for fb.exportReleaseBuild taskfor details on available parameters.

  3. Create a nightly build script that tells Eclipse to look for a build file and execute its target.

    The following examples specify build.xml as a build file, which executes MyTarget.

    If your nightly build script is on a Macintosh platform, you could run the following script:

    WORKSPACE="$HOME/Documents/Adobe Flash Builder" 
     
    # works with either FlashBuilder.app or Eclipse.app 
    "/Applications/Adobe Flash Builder/FlashBuilder.app/Contents/MacOS/FlashBuilder" \ 
        --launcher.suppressErrors \ 
        -noSplash \ 
        -application org.eclipse.ant.core.antRunner \ 
        -data "$WORKSPACE" \ 
        -file "$(pwd)/build.xml" MyTarget

    If your nightly build is on a Windows platform, you could run the following batch file:

    set WORKSPACE=%HOMEPATH%\Adobe Flash Builder 
     
    REM works with either FlashBuilderC.exe or eclipsec.exe 
    "C:\Program Files\Adobe\Adobe Flash Builder\FlashBuilderC.exe" ^ 
        --launcher.suppressErrors ^ 
        -noSplash ^ 
        -application org.eclipse.ant.core.antRunner ^ 
        -data "%WORKSPACE%" ^ 
        -file "%cd%\build.xml" MyTarget

fb.running Ant property

The fb.running Ant property has a value of true when Flash Builder is running. You can use this property when running scripts inside Flash Builder. For example:

<target name="myFlashBuilderTasks" if="fb.running"> 
    <fb.exportReleaseBuild ... /> 
</target> 

Eclipse Ant Tasks

Eclipse provides several Ant tasks you can incorporate as targets in your build script. For example:
  • eclipse.incrementalBuild

  • elicpse.refreshLocal

  • eclipse.convertpath

Consult the Eclipse documentation for more information on these scripts.

Parameters for fb.exportReleaseBuild task

Attribute

Description

Required?

Default Value

project

The project to build. Specify the name of a project in your Flash Builder workspace, without a path. For example, “MyFlexProject.”

Yes

n/a

application

The name of the application to compile. You can specify just the application name with no path or extension (for example: app1). To avoid ambiguity in naming, you can specify full path, relative to the project root (for example: src/app1.mxml).To compile all applications, specify ‘*’, or omit this attribute. When running against an AIR project, you can only specify a single application. The ‘*’ value is not allowed.

No

The default application of the project.

publishsource

Whether to publish the source of the application, allowing the user to view source files using the context menu View Source.

No

false

locale

Specifies the locale, for example, en-US. This value is passed to the compiler using the compiler’s -locale flag. If specified, this overrides any locale that has been specified in Flash Builder’s Additional Compiler Arguments field.

No

n/a

destdir

The output folder. The folder can be a relative path or an absolute path. If you specify a relative path, it is relative to the root of the project. If compiling an AIR project, the folder is a temporary directory that is deleted after the .air file has been created.

No

bin-release

failonerror

Indicates whether compilation errors cause the build to fail.

No

true

verbose

The <fb.exportReleaseBuild> task outputs additional information. For example, it lists the files that were packaged into the AIR file and how long each step of the process took.

No

false

package

For AIR projects only: Indicates whether to package the result into a .air or .airi file. If true, a .air or .airi file is created, and the temporary output directory (bin-release by default, set by the destdir attribute) is deleted.

If false, a .air or .airi file is not created, and the intermediate directory remains intact after compilation.

No

true

destfile

For AIR projects only: The filename of the .air or .airi file to create.

You can specify a relative path or absolute path. If you specify a relative path, the path is relative to the root of the project.

No

appname.air or appname.airi (in the project root)

certificate

For AIR projects only: The path to the certificate used to sign the AIR file.

No

If omitted, an unsigned .airi file is generated, which can be signed later.

password

For AIR projects only: The password for the certificate that is used to sign the AIR file. If this argument is omitted, an error message displays.

Caution: Specifying a literal value for a password can compromise security.

No

n/a

timestamp

For AIR projects only: Indicates whether the generated AIR file includes a timestamp.

No

false

Export Release Build wizard

When you run the Export Release Build wizard (Project > Export Release Build), the settings you make in the wizard are saved in the .actionScriptProperties file. A command line build that uses fb.exportReleaseBuild task picks up the settings from the wizard. The Export Release Build wizard saves the following settings:

  • View Source

    The source files you specify for View Source are saved. If you specify the publishsource parameter to fb.exportReleaseBuild, then the wizard includes these files as viewable source files.

    Important: For server projects, you can select the services folder when exporting source files. Exporting files that implement services has security implications. These files can expose access to your database, including user names and passwords. See Exporting source files with release version of an application.
  • For AIR projects, any additional output files that you specify in the wizard to include with the AIR or AIRI file.

Running command line builds on Linux and other platforms

The <fb.exportReleaseBuild> task is only supported on Windows and Mac platforms.

However, if you are writing a build script for another platform, use the -dump-config option to the mxmlc or compc compiler to write compiler configuration settings to a file. You can then use the -load-config option to read the configuration options.

Modify the configuration settings in the file as necessary. For example, change <debug>true</debug> to <debug>false</debug> if your nightly build is supposed to do a release build.

Run a command line build using Flash Builder compiler settings

  1. In Flash Builder, select Project > Properties > Flex Compiler

  2. In Additional Compiler Arguments, specify the following argument:

    -dump-config pathname, where pathname specifies the absolute path to a file on your system.

  3. Apply the changes in the Project window.

    The compiler settings are written to the specified file. Remove the -dump-config argument after you have verified that the file has been written.

  4. Modify the configuration settings as necessary.

  5. In your build script, run the compiler so it includes the saved compiler settings:

    mxmlc -load-config pathname

Limitations to command line builds

There are a few limitations to running command line builds using the <fb.exportReleaseBuild> task.

Running command line builds on Mac platforms using Eclipse 3.4

On Eclipse 3.4 on Mac platforms, headless build fails if the Eclipse installation path contains spaces.

Running command line builds on 64-bit platforms

Flash Builder runs on platforms that implement 32-bit Java. To run a command line build on platforms that support 64-bit Java (for example, Mac OS X Snow Leopard), add -d32 to the command-line options that are passed to Java. For example:

java -d32 ...