flex的ant编译脚本

来自:https://gist.github.com/944265

build.properties #
1
2
3
4
5
6
7
8
        
#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
build.xml #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
        
<?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>

你可能感兴趣的:(ant编译)