You use the mxmlc Flex Ant task to compile applications, modules, resource modules, and Cascading Style Sheets (CSS) SWF files. This task supports most mxmlc command-line compiler options, including aliases.
For more information on using the mxmlc command-line compiler, see Using mxmlc, the application compiler.
The mxmlc task requires the file attribute. The file attribute specifies the MXML file to compile. This attribute does not have a command-line equivalent because it is the default option on the command line.
The following mxmlc command-line compiler options are not supported by the mxmlc task:
The following example mxmlc task explicitly defines the source-path and library-path options, in addition to other properties such as incremental and keep-generated-actionscript. This example also specifies an output location for the resulting SWF file. This example defines two targets: main and clean. The main target compiles the Main.mxml file into a SWF file. The clean target deletes the output of the main target.
<?xml version="1.0" encoding="utf-8"?>
<!-- myMXMLCBuild.xml -->
<project name="My App Builder" basedir=".">
<taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar" />
<property name="FLEX_HOME" value="C:/flex/sdk"/>
<property name="APP_ROOT" value="apps"/>
<property name="DEPLOY_DIR" value="c:/jrun4/servers/default/default-war"/>
<target name="main">
<mxmlc
file="${APP_ROOT}/Main.mxml"
output="${DEPLOY_DIR}/Main.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="true"
incremental="true"
>
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<!-- List of path elements that form the roots of ActionScript
class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="../bundles/{locale}" />
</compiler.library-path>
<!-- Set size of output SWF file. -->
<default-size width="500" height="600" />
</mxmlc>
</target>
<target name="clean">
<delete dir="${APP_ROOT}/generated"/>
<delete>
<fileset dir="${DEPLOY_DIR}" includes="Main.swf"/>
</delete>
</target>
</project>