-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.xml
252 lines (206 loc) · 10.3 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
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
<?xml version="1.0"?>
<project name="BitmapDataCollectionSampler" basedir="." default="local-test">
<!-- This is 60% ripped off from RobotLegs - http://github.com/darscan/robotlegs-framework.
I am working on making my own but this one is so damn good I couldn't help myself. -->
<!-- identify properties file -->
<property file="build.properties"/>
<!-- Set up FlexUnit Ant tasks -->
<taskdef resource="flexUnitTasks.tasks" classpath="${lib.loc}/flexUnitTasks.jar"/>
<target name="usage">
<echo message=""/>
<echo message="${project.name} Build Usage"/>
<echo message="-----------------------------------"/>
<echo message="Main targets are:"/>
<echo message="local-test --> Build ${project.name} Launch, SWF, asdoc and test"/>
<echo message="compile-swc --> Build ${project.name} SWC, asdoc, test"/>
<echo message="compile-swf --> Build ${project.name} SWF"/>
<echo message=""/>
<echo message="Additional targets are:"/>
<echo message="setup-bin --> Build ${project.name} test, asdocs, setups up bin"/>
<echo message="asdoc --> Build ${project.name} test and generate asdocs"/>
<echo message="test --> Build ${project.name} runs unit tests"/>
<echo message="clean --> Remove all folders created by build script"/>
<echo message="init --> Clean and create build folders"/>
<echo message="-----------------------------------"/>
<echo message="disconnect --> Removed git files from project"/>
</target>
<!-- Deletes .git folder and .gitignore file -->
<target name="disconnect">
<delete dir="${basedir}/.git"/>
<delete file="${basedir}/.gitignore"/>
</target>
<!-- Clean Build and Report files -->
<target name="clean">
<!-- Remove all directories created during the build process -->
<echo>[clean] Removing Build and Report directories</echo>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${report.loc}" defaultexcludes="false">
<include name="**/*"/>
</fileset>
</delete>
<echo>[clean] Build and Report directories removed</echo>
</target>
<!-- Create directories needed for the build process -->
<target name="init" depends="clean">
<echo>[init] Creating Bin and Report directories</echo>
<mkdir dir="${bin.loc}"/>
<echo>[init] Bin and Report directories created</echo>
</target>
<!-- Run Unit Tests -->
<target name="test" depends="init" if="run.test">
<echo>[test] Running Unit Tests</echo>
<!-- Compile TestRunner.mxml as a SWF -->
<mkdir dir="${report.loc}"/>
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${test.src.loc}/${project.name}TestApp.mxml"/>
<arg value="-source-path=${main.src.loc}"/>
<arg value="-output=${bin.loc}/TestRunner.swf"/>
<arg value="-default-size=148,148"/>
<arg value="-default-background-color=0x320401"/>
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${lib.loc}"/>
<!-- So true. -->
<arg value="-incremental=true"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-headless-server=true"/>
</java>
<!-- Execute TestRunner.swf as FlexUnit tests and publish reports -->
<flexunit swf="bin/TestRunner.swf" toDir="${report.loc}" haltonfailure="false" verbose="true"
localTrusted="true" failureproperty="flexunit.failed"/>
<!-- Generate readable JUnit-style reports -->
<junitreport todir="${report.loc}">
<fileset dir="${report.loc}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${report.loc}/html"/>
</junitreport>
<echo>[test] Finished running Unit Tests</echo>
</target>
<!-- Opens JUnit Report when test fails -->
<target name="junitreport" depends="test" if="flexunit.failed">
<exec executable="open">
<arg line="-a ${browser} ${report.url}"/>
</exec>
<fail>Unit Tests Failed</fail>
</target>
<!-- Build Documentation -->
<target name="asdoc" depends="junitreport" if="run.asdoc">
<echo>[create-docs] Generating ASDOC documentation</echo>
<tstamp>
<format property="docgen.time" pattern="MM/dd/yyyy hh:mm aa" unit="hour"/>
</tstamp>
<java jar="${FLEX_HOME}/lib/asdoc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg line="-external-library-path ${lib.loc}"/>
<arg line="-doc-sources ${main.src.loc}"/>
<arg line="-source-path ${main.src.loc}"/>
<arg line="-output ${doc.loc}"/>
<arg line="-window-title '${project.name}'"/>
<arg line="-main-title '${project.name}'"/>
<arg line="-footer '${project.name} - Documentation generated at: ${docgen.time}'"/>
</java>
<echo>[create-docs] ASDOC documentation generated successfully</echo>
</target>
<target name="setup-bin" depends="asdoc">
<sync todir="${bin.loc}">
<fileset dir="${basedir}/build/bin-resources"/>
</sync>
<copy file="${basedir}/build/html-template/index.template.html" tofile="${bin.loc}/index.html"/>
<replace file="${bin.loc}/index.html" propertyFile="${basedir}/build/html-template/html.properties">
<replacefilter token="@width@" property="width"/>
<replacefilter token="@height@" property="height"/>
<replacefilter token="@example@" value="${project.name.versioned}"/>
<replacefilter token="@version_major@" property="version_major"/>
<replacefilter token="@version_minor@" property="version_minor"/>
<replacefilter token="@version_minor@" property="version_minor"/>
<replacefilter token="@version_revision@" property="version_revision"/>
</replace>
</target>
<!-- Compile Release SWF -->
<target name="compile-swf" depends="setup-bin">
<echo>[compile] Compiling SWF</echo>
<echo>[compile] Using Flex SDK at: ${FLEX_HOME}</echo>
<java jar="${FLEX_HOME}/lib/mxmlc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${main.src.loc}/${project.name}App.as"/>
<arg value="-source-path=${main.src.loc}"/>
<arg value="-output=${bin.loc}/swfs/${project.name.versioned}.swf"/>
<arg value="-static-link-runtime-shared-libraries=true"/>
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${lib.loc}"/>
<arg value="-library-path+=${air.swcs}"/>
<arg value="-default-background-color=0x000000"/>
<arg value="-default-frame-rate=31"/>
<arg value="-incremental=true"/>
<arg value="-debug=true"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-headless-server=true"/>
<arg value="-use-network=false"/>
</java>
<echo>[compile] Debug SWF ${project.name.versioned}.swf created successfully</echo>
</target>
<target name="local-test" depends="compile-swf" if="autolaunch.url">
<exec executable="open">
<arg line="-a ${browser} ${bin.loc}/index.html"/>
</exec>
</target>
<!-- Compile Release SWC -->
<target name="compile-swc" depends="asdoc">
<echo>[compile] Compiling release SWC</echo>
<echo>[compile] Using Flex SDK at: ${FLEX_HOME}</echo>
<java jar="${FLEX_HOME}/lib/compc.jar" dir="${FLEX_HOME}/frameworks" fork="true" failonerror="true">
<!-- Build our SWC with a versioned name. -->
<arg value="-output=${bin.loc}/${project.name.versioned}.swc"/>
<!-- We want all the org package classes in the SWC being built. -->
<arg value="-include-sources=${main.src.loc}/"/>
<!-- Include classes from SWCs in this folder, but only the ones we use. -->
<arg value="-library-path+=${lib.loc}"/>
<!-- Keep the magic alive. -->
<arg value="-keep-as3-metadata+=Inject"/>
<!-- Boolean mosh pit! -->
<arg value="-incremental=true"/>
<arg value="-static-link-runtime-shared-libraries=true"/>
<arg value="-verbose-stacktraces=true"/>
<arg value="-headless-server=true"/>
</java>
<echo>[compile] Release SWC ${project.name.versioned}.swc created successfully</echo>
</target>
<!-- Android Deployment -->
<target name="package-apk" depends="compile-swf">
<java jar="${FLEX_HOME}/lib/adt.jar" fork="true" failonerror="true">
<arg value="-package"/>
<arg value="-target"/>
<arg value="apk"/>
<arg value="-storetype"/>
<arg value="pkcs12"/>
<arg value="-keystore"/>
<arg value="${basedir}/build/codesigningCert.p12"/>
<arg value="-storepass"/>
<arg value="${password}"/>
<arg value="${basedir}/bin/${project.name.versioned}.apk"/>
<arg value="${basedir}/build/${project.name}-air-app.xml"/>
<arg value="-C"/>
<arg value="${basedir}/bin"/>
<arg value="."/>
</java>
</target>
<target name="deploy-to-phone" depends="package-apk">
<antcall target="uninstall-apk"/>
<exec executable="${adb}">
<arg value="-d"/>
<arg value="install"/>
<arg value="${bin.loc}/${project.name.versioned}.apk"/>
</exec>
</target>
<target name="deploy-to-emulator" depends="package-apk">
<exec executable="${adb}">
<arg value="-e"/>
<arg value="install"/>
<arg value="${bin.loc}/${project.name.versioned}.apk"/>
</exec>
</target>
<target name="uninstall-apk">
<exec executable="${adb}">
<arg value="uninstall"/>
<arg value="app.${app.package}"/>
</exec>
</target>
</project>