Skip to content

Instantly share code, notes, and snippets.

@zrong
Created April 27, 2011 13:44
Show Gist options
  • Save zrong/944265 to your computer and use it in GitHub Desktop.
Save zrong/944265 to your computer and use it in GitHub Desktop.
ant编译as项目的ant script(全面,smithfox提供)
#Flex SDK 路径
FLEX_HOME=D:\\flex\\flex_sdk_4.1.0.16076_mpl
#根目录
#APP_ROOT=G:\\riasource\\0.trunk
#ANT 安装目录
ANT_HOME=D:\\apache-ant-1.8.2
#本地部署目录(wamp/www)
#DEPLOY_DIR=E:/wamp/www/ihaveu2
<?xml version="1.0" encoding="utf-8"?>
<project name="Task Build Main Script" default="build" basedir=".">
<!-- 加载全局properties -->
<property file="./build.properties" />
<!-- 源文件路径 -->
<property name="SRC_DIR" value="${basedir}/src" />
<!-- assets路径 -->
<property name="ASSETS_DIR" value="${basedir}/src/assets" />
<!-- bin-debug路径 -->
<property name="BIN_DIR" value="${basedir}/bin-debug" />
<!-- lib路径 -->
<property name="LIBS_DIR" value="${basedir}/libs" />
<!-- 引入flexTasks.jar -->
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<!--
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${ANT_HOME}/lib/ant-contrib-1.0b3" />
</classpath>
</taskdef>
-->
<target name="clean">
<delete>
<fileset dir="${BIN_DIR}" >
<include name="**/*.swf" />
<include name="**/*.cache" />
</fileset>
</delete>
</target>
<target name="createRSL">
<macrodef name="optimize-rsl">
<attribute name="rsl-dir" />
<attribute name="swc-dir" />
<attribute name="swc-name" />
<sequential>
<unzip src="@{swc-dir}/@{swc-name}.swc" dest="@{rsl-dir}">
<patternset>
<include name="library.swf" />
</patternset>
</unzip>
<move file="@{rsl-dir}/library.swf" tofile="@{rsl-dir}/@{swc-name}.swf" />
</sequential>
</macrodef>
<optimize-rsl rsl-dir="${BIN_DIR}/rsls" swc-dir="${LIBS_DIR}" swc-name="sparktree" />
<optimize-rsl rsl-dir="${BIN_DIR}/rsls" swc-dir="${LIBS_DIR}" swc-name="SWFAddress" />
<optimize-rsl rsl-dir="${BIN_DIR}/rsls" swc-dir="${LIBS_DIR}" swc-name="flex4_ofc2" />
<optimize-rsl rsl-dir="${BIN_DIR}/rsls" swc-dir="${LIBS_DIR}" swc-name="smf" />
</target>
<target name="build" depends="clean, createRSL, buildMain">
<macrodef name="build-module">
<attribute name="module-name" />
<sequential>
<mxmlc maxmemory="1024m" fork="true"
file="${SRC_DIR}/modules/@{module-name}.mxml"
output="${BIN_DIR}/modules/@{module-name}.swf"
incremental="false">
<jvmarg value="-Xmx2048m" />
<jvmarg value="-Xms512m" />
<jvmarg value="-XX:MaxPermSize=512m" />
<!-- 方便可以进行远程debug -->
<compiler.debug>true</compiler.debug>
<compiler.optimize>true</compiler.optimize>
<source-path path-element="${SRC_DIR}" />
<use-network>true</use-network>
<load-externs>linkreport.xml</load-externs>
<static-link-runtime-shared-libraries>false</static-link-runtime-shared-libraries>
<!-- Get default compiler options.
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
-->
<!-- 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>
-->
<!-- 项目需要用到的locale名字,其中在SDK 4.1 里面framework locale目录zh_tw已经改成zh_TW,但千万别信,使用的时候还是要写成zh_tw -->
<!--
<locale>en_US</locale>
<locale>zh_CN</locale>
<locale>zh_tw</locale>
-->
<!--项目的多语言及配置文件目录-->
<!--
<source-path path-element="${CONFIG_DIR}/en_US" />
<source-path path-element="${CONFIG_DIR}/zh_CN" />
<source-path path-element="${CONFIG_DIR}/zh_tw" />
-->
<!-- 依赖的flex 4.1框架的RSL, 注意:顺序不能乱!若不写这一段则会报错:VerifyError: Error #1014: 无法找到类 。估计是由于下面自己定义的RSL依赖次序被优先了 -->
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
<url rsl-url="../frameworkrsls/framework.swz"/>
<url rsl-url="../frameworkrsls/framework.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/framework_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/textLayout.swc">
<url rsl-url="../frameworkrsls/textLayout.swz"/>
<url rsl-url="../frameworkrsls/textLayout.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/tlf/1.1.0.604/textLayout_1.1.0.604.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<!--
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/libs/osmf.swc">
<url rsl-url="../frameworkrsls/osmf_flex.swz"/>
<url rsl-url="../frameworkrsls/osmf_flex.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/osmf_flex.4.0.0.13495.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
-->
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/spark.swc">
<url rsl-url="../frameworkrsls/spark.swz"/>
<url rsl-url="../frameworkrsls/spark.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/spark_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/sparkskins.swc">
<url rsl-url="../frameworkrsls/sparkskins.swz"/>
<url rsl-url="../frameworkrsls/sparkskins.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/sparkskins_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/rpc.swc">
<url rsl-url="../frameworkrsls/rpc.swz" />
<url rsl-url="../frameworkrsls/rpc.swf" />
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/rpc_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<!-- 依赖的第三方RSL, 如果有依赖关系,则应该按照依赖次序 进行定义-->
<runtime-shared-library-path path-element="${LIBS_DIR}/sparktree.swc">
<url rsl-url="../rsls/sparktree.swf" policy-file-url=""/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${LIBS_DIR}/SWFAddress.swc">
<url rsl-url="../rsls/SWFAddress.swf" policy-file-url=""/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${LIBS_DIR}/flex4_ofc2.swc">
<url rsl-url="../rsls/flex4_ofc2.swf" policy-file-url=""/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${LIBS_DIR}/smf.swc">
<url rsl-url="../rsls/smf.swf" policy-file-url=""/>
</runtime-shared-library-path>
<!-- 指定哪些包是不需要编译进输出的swf, 不写这段会把框架打包进index.swf里面去 -->
<external-library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
<include name="*.swc" />
<include name="air/*.swc" />
</external-library-path>
<external-library-path dir="${LIBS_DIR}" append="true">
<include name="*.swc" />
</external-library-path>
</mxmlc>
</sequential>
</macrodef>
<build-module module-name="module_init" />
<build-module module-name="module_systeminfo" />
<build-module module-name="module_cpumem" />
<build-module module-name="module_netio" />
<build-module module-name="module_diskio" />
<build-module module-name="module_systemstatus" />
<build-module module-name="module_diskstatus" />
<build-module module-name="module_volumestatus" />
<build-module module-name="module_foldstatus" />
<build-module module-name="module_volumecreate" />
<build-module module-name="module11" />
<build-module module-name="module12" />
</target>
<!-- 构建web项目 -->
<target name="buildMain" >
<!--
<exec executable="svnversion" outputproperty="revisionVersion" />
<copy todir="${BIN_DIR}">
<fileset dir="${SRC_DIR}/web_runtime">
<include name="**/**" />
</fileset>
</copy>
-->
<!--
<copy todir="${BIN_DIR}/assets">
<fileset dir="${ASSETS_DIR}">
<include name="**/**" />
</fileset>
<fileset dir="${ASSETS_DIR}/air_runtime">
<include name="**/**" />
</fileset>
</copy>
-->
<mxmlc file="${SRC_DIR}/com/istorage/main.mxml"
output="${BIN_DIR}/main.swf"
incremental="false">
<!-- 方便可以进行远程debug -->
<compiler.debug>true</compiler.debug>
<compiler.optimize>true</compiler.optimize>
<source-path path-element="${SRC_DIR}" />
<use-network>true</use-network>
<link-report>linkreport.xml</link-report>
<static-link-runtime-shared-libraries>false</static-link-runtime-shared-libraries>
<!-- Get default compiler options.
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
-->
<!-- 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>
-->
<!-- 项目需要用到的locale名字,其中在SDK 4.1 里面framework locale目录zh_tw已经改成zh_TW,但千万别信,使用的时候还是要写成zh_tw -->
<!--
<locale>en_US</locale>
<locale>zh_CN</locale>
<locale>zh_tw</locale>
-->
<!--项目的多语言及配置文件目录-->
<!--
<source-path path-element="${CONFIG_DIR}/en_US" />
<source-path path-element="${CONFIG_DIR}/zh_CN" />
<source-path path-element="${CONFIG_DIR}/zh_tw" />
-->
<!-- 依赖的flex 4.1框架的RSL, 注意:顺序不能乱!若不写这一段则会报错:VerifyError: Error #1014: 无法找到类 。估计是由于下面自己定义的RSL依赖次序被优先了 -->
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
<url rsl-url="frameworkrsls/framework.swz"/>
<url rsl-url="frameworkrsls/framework.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/framework_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/textLayout.swc">
<url rsl-url="frameworkrsls/textLayout.swz"/>
<url rsl-url="frameworkrsls/textLayout.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/tlf/1.1.0.604/textLayout_1.1.0.604.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<!--
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/libs/osmf.swc">
<url rsl-url="frameworkrsls/osmf_flex.swz"/>
<url rsl-url="frameworkrsls/osmf_flex.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/osmf_flex.4.0.0.13495.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
-->
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/spark.swc">
<url rsl-url="frameworkrsls/spark.swz"/>
<url rsl-url="frameworkrsls/spark.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/spark_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/sparkskins.swc">
<url rsl-url="frameworkrsls/sparkskins.swz"/>
<url rsl-url="frameworkrsls/sparkskins.swf"/>
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/sparkskins_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/rpc.swc">
<url rsl-url="frameworkrsls/rpc.swz" />
<url rsl-url="frameworkrsls/rpc.swf" />
<url rsl-url="http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/rpc_4.1.0.16076.swz" policy-file-url="http://fpdownload.adobe.com/pub/swz/crossdomain.xml"/>
</runtime-shared-library-path>
<!-- 依赖的第三方RSL, 如果有依赖关系,则应该按照依赖次序 进行定义-->
<runtime-shared-library-path path-element="${LIBS_DIR}/sparktree.swc">
<url rsl-url="rsls/sparktree.swf" policy-file-url=""/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${LIBS_DIR}/SWFAddress.swc">
<url rsl-url="rsls/SWFAddress.swf" policy-file-url=""/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${LIBS_DIR}/flex4_ofc2.swc">
<url rsl-url="rsls/flex4_ofc2.swf" policy-file-url=""/>
</runtime-shared-library-path>
<runtime-shared-library-path path-element="${LIBS_DIR}/smf.swc">
<url rsl-url="rsls/smf.swf" policy-file-url=""/>
</runtime-shared-library-path>
<!-- 指定哪些包是不需要编译进输出的swf, 不写这段会把框架打包进index.swf里面去 -->
<external-library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
<include name="*.swc" />
<include name="air/*.swc" />
</external-library-path>
<external-library-path dir="${LIBS_DIR}" append="true">
<include name="*.swc" />
</external-library-path>
</mxmlc>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment