【发布时间】:2011-10-23 09:53:59
【问题描述】:
如何构建一个 Ant 脚本来输出 swfs 和 air 包,并在编译期间根据我想要的目标使用不同的类?
例如,我正在构建一个适用于网络、移动设备和桌面的应用程序。在某些情况下,我的类将只使用 AIR 组件。我希望能够创建在为 Web 输出 swf 时不包含这些类的 ANT 构建脚本。我该怎么做?
【问题讨论】:
标签: flash actionscript-3 ant air flash-builder
如何构建一个 Ant 脚本来输出 swfs 和 air 包,并在编译期间根据我想要的目标使用不同的类?
例如,我正在构建一个适用于网络、移动设备和桌面的应用程序。在某些情况下,我的类将只使用 AIR 组件。我希望能够创建在为 Web 输出 swf 时不包含这些类的 ANT 构建脚本。我该怎么做?
【问题讨论】:
标签: flash actionscript-3 ant air flash-builder
这是我针对类似情况所做的:
<target name="define.compile.task" depends="initflex">
<presetdef name="flex.build">
<mxmlc file="${src.dir}/${src.file.path}"
output="${output.dir}/${output.file.path}" ...>
<compiler.source-path path-element="${src.dir}"/>
...
</mxmlc>
</presetdef>
</target>
<target name="parametrized.web.build" depends="define.compile.task">
<flex.build>
<compiler.define name="CONFIG::AllowAirComponents" value="false" />
</flex.build>
</target>
<target name="parametrized.air.build" depends="define.compile.task">
<flex.build configname="airmobile">
<compiler.define name="CONFIG::AllowAirComponents" value="true" />
</flex.build>
</target>
然后,我可以定义类似的目标
<target name="buildwebclass1">
<antcall target="parametrized.web.build">
<param name="src.file.path" value="path/to/MyClass.as"/>
<param name="output.file.path" value="MyClass.swf"/>
</antcall>
</target>
或者:
<target name="buildairclass1">
<antcall target="parametrized.air.build">
<param name="src.file.path" value="path/to/MyAirClass.as"/>
<param name="output.file.path" value="MyAirClass.swf"/>
</antcall>
<exec executable="${FLEX_HOME}/bin/adt" failonerror="true">
... (adt arguments)
</exec>
</target>
如果我有一些公共代码工厂仅在必要时实例化 air 类,我会用 CONFIG::AllowAirComponents { ... } 包装它,这样我的 AIR 特定类就不会干扰 Web 构建。
希望这会有所帮助!
【讨论】: