Chr*_*Rea 3 ant flexbuilder build-process flex3 mxmlc
我正在构建一个需要在两种不同的部署方案下运行的Flex应用程序:
首先,该应用程序将托管在Web上.SWF加载一些外部资源(图像,文本),因此需要网络访问,这是Flex Builder 3默认构建标志"-use-network=true".我不需要做任何特别的事情; 它只是工作.
其次,应用程序将写入CD并启用自动运行以启动托管SWF的index.html.SWF 仍然需要能够加载相同的外部资源,这些资源驻留在子文件夹中的CD上.由于这些文件位于CD上,因此它们被视为本地文件,因此Flash安全性要求使用标志来构建SWF "-use-network=false".我将它添加到Flex项目的Properties对话框中"Flex Compiler"下的"Additional compiler arguments"文本框中.
这一切都按预期工作,但必须手动修改Flex Builder项目设置以根据具体情况添加或删除该标志是很繁琐的.
理想情况下,我想只构建一次项目并拥有多个输出文件夹:一个用于网络部署方案,另一个用于本地部署方案.
最好的方法是什么?是转向Ant构建的方式,还是有更简单的方法?如果Ant构建配置是正确的方法,您是否有一个示例来共享这样的多个构建配置?
谢谢你的帮助!
一旦你了解了Ant构建,它将使你的生活更轻松.构建多个构建文件与单个构建文件没有什么不同,您只需使用适当的设置在构建中添加一个额外的任务(您也可以在ant中使用循环,但这会增加复杂性)
因此,从文档扩展Flex Ant Tasks示例,这样的事情应该工作(未经测试):
<?xml version="1.0" encoding="utf-8"?>
<!-- myMXMLCBuild.xml -->
<project name="My App Builder" basedir="." default="main">
<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" depends="clean, compile1, compile2">
</target>
<target name="compile1">
<mxmlc
file="${APP_ROOT}/Main.mxml"
output="${DEPLOY_DIR}/Main.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="true"
incremental="true"
use-network="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="compile2">
<mxmlc
file="${APP_ROOT}/Main.mxml"
output="${CD_DEPLOY_DIR}/Main.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="true"
incremental="true"
use-network="false"
>
<!-- 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>
Run Code Online (Sandbox Code Playgroud)
作为旁注,如果您要在eclipse/Flash Builder中运行Ant构建,您现在也可以增加内存.