-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.xml
191 lines (181 loc) · 6.99 KB
/
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- Debug and Package the AIR Flex 4 Project -->
<!-- Author : zrong -->
<!-- Blog: zengrong.net -->
<!-- E-mail : zrongzrong@gmail.com -->
<!-- Creation : 2012-10-29 -->
<!-- Modification : 2013-06-13 -->
<project name="airPackager" default="packswf">
<property file="build.properties" />
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<if>
<or>
<istrue value="${standalone}"/>
<not>
<available property="fd.exists" file="${FD_PROJECT}"/>
</not>
</or>
<!-- 若单独使用,或者找不到FD配置,那么根据变量自动生成 -->
<then>
<property name="swf.name" value="${MAIN_NAME}.swf"/>
<property name="swf.file" value="${BIN_DIR}/${swf.name}"/>
<property name="main.name" value="${MAIN_NAME}.mxml"/>
<property name="main.file" value="${SRC_DIR}/${MAIN_PATH}${main.name}"/>
</then>
<!-- 否则读取FD配置的内容 -->
<else>
<echo>Found the Flash Develop project: ${FD_PROJECT}.</echo>
<!-- 读取FD配置,获取FD导出的swf文件,替换原来的变量值 -->
<xmlproperty file="${FD_PROJECT}" keeproot="false"/>
<!-- 获取Flash Develop项目文件中配置的swf文件 -->
<property name="swf.file" value="${basedir}/${output.movie(path)}" />
<!-- 不包含目录部分的文件名 -->
<propertyregex property="swf.name" input="${swf.file}" regexp=".*\\([\w]*.swf)" select="\1"/>
<!-- 获取Flash Develop项目文件中配置的主类文件 -->
<property name="main.file" value="${basedir}/${compileTargets.compile(path)}" />
<!-- 不包含目录部分的文件名 -->
<propertyregex property="main.name" input="${main.file}" regexp=".*\\([\w]*.mxml)" select="\1"/>
</else>
</if>
<echo>main.file:${main.file}</echo>
<echo>main.name:${main.name}</echo>
<echo>swf.file:${swf.file}</echo>
<echo>swf.name:${swf.name}</echo>
<echo>FLEX_HOME:${FLEX_HOME}</echo>
<target name="clearswf">
<delete file="${swf.file}"/>
</target>
<!-- package the swf file -->
<target name="packswf" depends="clearswf">
<condition property="var.debug" value="${var.debug}" else="true">
<isset property="var.debug" />
</condition>
<condition property="var.optimize" value="${var.optimize}" else="true">
<isset property="var.optimize" />
</condition>
<condition property="var.swfversion" value="${var.swfversion}" else="17">
<isset property="var.swfversion" />
</condition>
<echo>Building swf file ${swf.file}...</echo>
<echo>The main file is ${main.file}.</echo>
<echo>debug:${var.debug} optimize:${var.optimize} swfversion:${var.swfversion}</echo>
<java jar="${FLEX_HOME}/lib/mxmlc.jar" fork="true" failonerror="true" dir="${FLEX_FRAMEWORKS}">
<arg line="-output ${swf.file}"/>
<arg line="-swf-version ${var.swfversion}"/>
<arg line="-source-path ${SRC_DIR}"/>
<arg value="-load-config+=air-config.xml"/>
<arg value="-library-path+=${LIB_DIR}"/>
<!--
<arg value="-l+=${ANE_DIR}/com.sanguo.ios.ane"/>
-->
<arg value="-debug=${var.debug}"/>
<arg value="-optimize=${var.optimize}"/>
<arg value="${main.file}"/>
</java>
</target>
<!-- 创建AIR 打包需要的p12文件 -->
<target name="createCertificate">
<echo>Delete old certificate file.</echo>
<delete file="${AIR_CERT_FILE}"/>
<echo>Create a new certificate file ${AND_CERT_FILE}.</echo>
<java jar="${FLEX_HOME}/lib/adt.jar" fork="true" failonerror="true">
<arg value="-certificate" />
<arg line="-validityPeriod 25" />
<arg line="-cn ${AIR_CERT_NAME}" />
<arg value="1024-RSA" />
<arg value="${AIR_CERT_FILE}" />
<arg value="${AIR_CERT_PASS}" />
</java>
</target>
<!-- 验证app.xml文件中的内容是否合适 -->
<target name="replaceAPPXML">
<xmlproperty file="${APP_XML}" keeproot="false"/>
<echo>Replace the appid from ${id} to ${APP_ID} in ${APP_XML}.</echo>
<!-- 将application.xml中的appid替换成配置中的值 -->
<replaceregexp file="${APP_XML}" encoding="UTF-8">
<regexp pattern="(\x3Cid\x3E).*(\x3C/id\x3E)"/>
<substitution expression="\1${APP_ID}\2"/>
</replaceregexp>
<echo>Replace the content from ${initialWindow.content} to ${swf.name} in ${APP_XML}.</echo>
<!-- 将application.xml中的content替换成swf.name的值 -->
<replaceregexp file="${APP_XML}" encoding="UTF-8">
<regexp pattern="(\x3Ccontent\x3E).*(\x3C/content\x3E)"/>
<substitution expression="\1${swf.name}\2"/>
</replaceregexp>
</target>
<!-- Copy the assets to bin directory. -->
<target name="copyBinAssets">
<mkdir dir="${BIN_DIR}"/>
<delete dir="${BIN_DIR}/icon"/>
<delete dir="${BIN_DIR}/locale"/>
<echo>Copy ${ASSET_DIR} to ${BIN_DIR}</echo>
<copy todir="${BIN_DIR}">
<fileset dir="${ASSET_DIR}">
<include name="icon/**"/>
<include name="locale/**"/>
</fileset>
</copy>
</target>
<!-- Copy the assets to temp directory. -->
<target name="copyPackageAssets">
<mkdir dir="${TEMP_DIR}"/>
<echo>Copy ${TEMP_DIR} to ${BIN_DIR}</echo>
<copy todir="${TEMP_DIR}">
<fileset dir="${BIN_DIR}">
<include name="**"/>
</fileset>
</copy>
</target>
<!-- Package a APK or IPA file. -->
<target name="packager" depends="copyPackageAssets,replaceAPPXML">
<fail unless="var.type"/>
<fail unless="var.signing"/>
<fail unless="var.output"/>
<mkdir dir="${DIST_DIR}"/>
<echo>Packager a ${var.type}${var.target}</echo>
<echo>The signing is ${var.signing}</echo>
<echo>The output file is ${var.output}</echo>
<echo>The options are ${var.options}</echo>
<echo>${FLEX_HOME}/lib/adt.jar -package ${var.signing} ${var.options} -target ${var.type}${var.target} ${var.output} ${APP_XML} ${var.fileordir} ${ANE_DIR_ARGS}</echo>
<java jar="${FLEX_HOME}/lib/adt.jar" fork="true" failonerror="true">
<arg value="-package"/>
<arg line="${var.signing}"/>
<arg line="${var.options}"/>
<arg line="-target ${var.type}${var.target}"/>
<arg line="${var.output}"/>
<arg value="${APP_XML}"/>
<arg line="${var.fileordir}"/>
<arg line="${ANE_DIR_ARGS}"/>
</java>
<delete dir="${TEMP_DIR}"/>
</target>
<!-- Start ADL for APP_XML -->
<target name="startADL" depends="replaceAPPXML">
<property name="ADL" value="${FLEX_HOME}/bin/adl"/>
<condition property="var.adl" value="${ADL}.exe" else="${ADL}">
<os family="windows"/>
</condition>
<echo>OS family is ${os.name}. The adl is ${var.adl}.</echo>
<exec executable="${FLEX_HOME}/bin/adl.exe">
<arg line="${APP_XML} ${BIN_DIR}"/>
</exec>
</target>
<!-- Build a debug swf file, and start ADL to debug it. -->
<target name="runSimulatorDebug">
<echo>runSimulatorDebug ${APP_XML} ${BIN_DIR}</echo>
<antcall target="packswf">
<param name="var.debug" value="true"/>
<param name="var.optimize" value="false"/>
</antcall>
<antcall target="startADL"/>
</target>
<!-- Build a release swf file, and package it to a air file -->
<target name="packair" depends="copyBinAssets">
<echo>packair ${APP_XML} ${BIN_DIR}</echo>
<antcall target="packswf">
<param name="var.debug" value="false"/>
<param name="var.optimize" value="true"/>
</antcall>
<antcall target="packager"/>
</target>
</project>