ant是一个基于JAVA的自动化脚本引擎,脚本格式为XML。除了做JAVA编译相关任务外,ANT还可以通过插件实现很多应用的调用。
平时我们在编译Flex文件时都是使用的FlexBuilder提供的编译功能,也可以实现自动编译的功能,但如果项目一大,涉及到一些公共组件的调用比较多时,这种编译就不是很方便了.
在习惯了利用ant自动化编译部署Java应用程序的方便功能以后,自然想到也要利用ant的脚本功能进行Flex的自动编译,以下就是我写的关于编译Flex的build.xml文件(附件中有实例工程压缩文件),实现了自动编译与生成API文档的功能:
<?xml version="1.0"?>
<project name="flex_examples" basedir="../" default="compile_modified">
<property file="./build/build.properties" />
<!--
Have you edit the properties file to make sure the paths are right on your system?
-->
<target name="properties">
<fail unless="asdoc.exe">The "asdoc.exe" property must be set in ${build.dir}/build.properties.</fail>
<fail unless="compc.exe">The "compc.exe" property must be set in ${build.dir}/build.properties.</fail>
<fail unless="mxmlc.exe">The "mxmlc.exe" property must be set in ${build.dir}/build.properties.</fail>
</target>
<!--
Extension for ANT to allow for tasks like "for" and "propertyregex"
-->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="libs/ant/ant-contrib.jar" />
</classpath>
</taskdef>
<!--
Generate the main applications using the library
-->
<target name="compile_modified" depends="properties">
<!--
Loop over all of the Sample applications in the mains directory,
compile them, and place the resulting .swf next to the application
.mxml file.
-->
<for param="file">
<!-- Find the sample applications -->
<fileset dir="${src.dir}">
<!--
The modified selector will only select files that have been
modified since the mains target was last run. This means we
can update a single main, then run the mains target and
only the updated main will get recompiled.
-->
<modified/>
<include name="**/*${application.name.flag}.mxml" />
<!--
For only building specific mains, comment out
the line above, and uncomment the line below and modify
as appropriate.
-->
<!--<include name="**/HorizontalAxisDataSelector_Sample.mxml" />-->
</fileset>
<sequential>
<propertyregex property="mainApplicationName" override="yes" input="@{file}"
regexp=".*\${file.separator}(.*)${application.name.flag}.mxml" replace="\1" />
<propertyregex property="mainFolderName" override="yes" input="@{file}"
regexp="(.*)\${file.separator}(.*)${application.name.flag}.mxml" replace="\1" />
<exec executable="${mxmlc.exe}" dir="${basedir}">
<arg line="'@{file}'" />
<arg line="-o '${mainFolderName}/${mainApplicationName}${application.name.flag}.swf'" />
<arg line="-l '${lib.dir}'" />
<arg line="-l '${flexsdk.lib.dir}'" />
<arg line="-sp '${src.dir}'" />
<arg line="-optimize" />
<arg line="-locale ${flexsdk.locale}" />
<arg line="-l '${flexsdk.locale.dir}'" />
</exec>
</sequential>
</for>
</target>
<!--
Generate ASDoc output for the library
-->
<target name="docs" depends="properties">
<!-- Clean out the contents of the doc directory, without deleting "docs" -->
<delete includeemptydirs="true">
<fileset dir="${docs.dir}" includes="**/*" />
</delete>
<exec executable="${asdoc.exe}" spawn="no">
<!-- Place the documentation in the "docs" directory -->
<arg line="-o '${docs.dir}'" />
<!-- Specify the main source path as "src" -->
<arg line="-sp '${src.dir}'" />
<!-- Document all of the classes in the "src" tree -->
<arg line="-ds '${src.dir}' " />
<!-- Include the library name in the window title -->
<arg line="-window-title '${library.name}' "/>
<arg line="-templates-path '${flexsdk.templates.dir}' "/>
</exec>
</target>
</project>
分享到:
相关推荐
利用ant编译flex脚本,可以直接在你的程序中使用。
直接使用flex的sdk生成swc文件,很繁琐,而且对于大项目来说,是个头痛的事情。ant在对java打包生成jar时,它优良的设计显露无疑,这里我们使用它,来生成swc,完成项目编译打包。
在编译flex/java工程是采用Ant自动编译,将编译好的工程进行打包发布.
在编译flex/java工程是采用Ant自动编译,将编译好的工程进行打包发布
flex 使用ant 脚本来编译flex源码示例脚本。方便学习,共享一下!
博文链接:https://nstar.iteye.com/blog/129653
内含修改源码所需的环境配置说明,修改后用ant发布即可
使用mxmlc和Ant编译Flex应用程序 25.10节. 使用ASDoc和Ant生成文档 25.11节. 使用Rake编译Flex应用程序 25.12节. 使用ExpressInstall 25.13节. 使用Flex Builder 3的Memory Profiling查看内存快照 第二十六章...
anetoolkit AIR的ANE工具包 提供以下功能: 安装APK文件 调用各种设置面板 振动 ...修改其中的 flex.sdk 和 android.sdk 变量为正确的路径 运行 ant android-ane 作者 ANEToolkit 由 和 共同完成。