forked from purdrew/incubator-cordova-blackberry-webworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
304 lines (226 loc) · 9.23 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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<project name="Create & Update a Cordova BlackBerry WebWorks Project" default="help">
<!-- LOAD VERSION -->
<loadfile property="version" srcFile="VERSION">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<!-- LOAD PROPERTIES -->
<property name="template.project.dir" location="template/project" />
<property name="template.dist.dir" location="template/dist" />
<property name="build.dir" location="build" />
<property name="update.dir" value="lib/cordova.${version}" />
<property name="dist.path" location="dist" />
<property name="dist.www.path" location="${dist.path}/www" />
<property name="dist.project.path" location="${dist.path}/sample" />
<property name="jar.src" location="framework/ext/src" />
<property name="jar.path" value="ext" />
<property name="jar.basename" value="cordova.${version}.jar" />
<property name="jar.file" value="${jar.path}/${jar.basename}" />
<property name="playbook.js.src" location="javascript/playbook" />
<property name="playbook.js.path" value="javascript/playbook" />
<property name="playbook.js.file" value="${playbook.js.path}/playbook.js" />
<property name="playbook.ext.src" location="framework/ext-air" />
<property name="playbook.ext.path" value="ext-air" />
<property name="js.src" location="javascript" />
<property name="js.path" value="javascript" />
<property name="js.basename" value="cordova-${version}.js" />
<property name="js.file" value="${js.path}/${js.basename}" />
<!-- BUILD JAVASCRIPT -->
<target name="build-javascript">
<mkdir dir="${build.dir}/${js.path}" />
<!-- BB Javascript -->
<concat destfile="${build.dir}/${js.file}" append="false">
<filelist dir="${js.src}" files="_cordova.js,webWorksPluginManager.js,console.js" />
<fileset dir="${js.src}/blackberry" includes="*.js"/>
<filelist dir="${js.src}" files="device.js,file.js" />
<fileset dir="${js.src}" excludes="_cordova.js,webWorksPluginManager.js,console.js,device.js,file.js">
<include name="*.js" />
</fileset>
</concat>
<!-- PB Javascript -->
<mkdir dir="${build.dir}/${playbook.js.path}" />
<concat destfile="${build.dir}/${playbook.js.path}/${js.basename}" append="false">
<fileset dir="${js.src}" includes="*.js" />
</concat>
<concat destfile="${build.dir}/${playbook.js.path}/${js.basename}" append="true">
<fileset dir="${js.src}/playbook" includes="*.js"/>
</concat>
</target>
<!-- BUILD BLACKBERRY EXTENSION -->
<target name="build-bb-extension">
<mkdir dir="${build.dir}/${jar.path}" />
<zip destfile="${build.dir}/${jar.file}">
<fileset dir="${jar.src}" includes="library.xml" />
<fileset dir="${jar.src}" includes="**/*.java" />
</zip>
</target>
<!-- BUILD PLAYBOOK EXTENSION -->
<target name="build-pb-extension">
<!-- Copy Ext -->
<mkdir dir="${build.dir}/${playbook.ext.path}" />
<copy todir="${build.dir}/${playbook.ext.path}">
<fileset dir="${playbook.ext.src}" />
</copy>
</target>
<!-- CREATE A PROJECT -->
<target name="create" depends="clean, build-javascript, build-bb-extension, build-pb-extension">
<fail unless="project.path" message="You must give a project PATH. Use the argument -Dproject.path="C:\dev\my_project"" />
<available file="${project.path}" property="project.exists" />
<fail if="project.exists" message="The project path must be an empty directory." />
<!-- create project using template directory -->
<mkdir dir="${project.path}" />
<copy todir="${project.path}">
<fileset dir="${template.project.dir}" />
</copy>
<!-- update project files to reference cordova.x.x.x.js -->
<replaceregexp match="cordova\.js" replace="${js.basename}" byline="true">
<fileset file="${project.path}/www/index.html" />
<fileset file="${project.path}/build.xml" />
</replaceregexp>
<!-- copy cordova.js -->
<copy todir="${project.path}/www">
<fileset dir="${build.dir}/${js.path}" />
</copy>
<!-- copy ext/ -->
<copy todir="${project.path}/www/ext">
<fileset dir="${build.dir}/${jar.path}" />
</copy>
<!-- copy ext-air/ -->
<copy todir="${project.path}/www/ext-air">
<fileset dir="${build.dir}/${playbook.ext.path}" />
</copy>
<!-- save release -->
<mkdir dir="${project.path}/${update.dir}" />
<copy todir="${project.path}/${update.dir}">
<fileset dir="${build.dir}" />
</copy>
<echo>
Project Creation Complete!
==========================
Getting Started:
----------------
cd ${project.path}
ant help
</echo>
</target>
<!-- DISTRIBUTION -->
<target name="dist" depends="">
<!-- create a sample project -->
<antcall target="create">
<param name="project.path" value="${dist.project.path}" />
</antcall>
<!-- copy dist template (README.md) -->
<copy todir="${dist.path}">
<fileset dir="${template.dist.dir}" />
</copy>
<!-- copy cordova.jar -->
<copy todir="${dist.www.path}/ext">
<fileset dir="${build.dir}/${jar.path}" />
</copy>
<!-- copy cordova.js -->
<copy todir="${dist.www.path}">
<fileset dir="${build.dir}/${js.path}" />
</copy>
<!-- copy config.xml -->
<copy todir="${dist.www.path}">
<fileset file="${template.project.dir}/www/config.xml" />
</copy>
<!-- copy plugins.xml -->
<copy todir="${dist.www.path}">
<fileset file="${template.project.dir}/www/plugins.xml" />
</copy>
<echo>
Distribution Complete!
======================
Version:
--------
${version}
Path:
-----
${dist.path}
</echo>
</target>
<target name="version">
<replace dir="." token="${version}" value="${value}" />
<echo>
Version Update Complete!
========================
Version:
--------
Previous: ${version}
Current: ${value}
Remember to:
------------
Review and commit the version update.
$ git diff
$ git commit -am "Update to version ${value}"
$ git tag ${value}
</echo>
</target>
<!-- UPDATE A PROJECT -->
<target name="update" depends="clean, build-javascript, build-bb-extension, build-pb-extension">
<fail unless="project.path" message="You must give a project PATH. Use the argument -Dproject.path="C:\dev\my_project"" />
<available file="${project.path}" property="project.exists" />
<fail unless="project.exists" message="The project path cannot be empty." />
<!-- save release -->
<mkdir dir="${project.path}/${update.dir}" />
<copy todir="${project.path}/${update.dir}">
<fileset dir="${build.dir}" />
</copy>
<echo>
Update complete!
================
Cordova ${version} has been created.
Update does not alter your project files.
See below for instructions to install Cordova ${version}.
Where:
------
${project.path}/${update.dir}
Install:
--------
1. Install the Java Extension:
- delete /www/${jar.path}/cordova.jar
- copy /${update.dir}/${jar.file}
to /www/${jar.file}
2. Install the JavaScript library:
- delete /www/cordova.js
- copy /${update.dir}/${js.file}
to /www/${js.basename}
3. Update JavaScript references:
- <script type="text/javascript" src="${js.basename}"></script>
</echo>
</target>
<!-- CLEAN -->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.path}" />
</target>
<!-- HELP -->
<target name="help">
<echo>
NAME
${ant.project.name}
SYNOPSIS
ant COMMAND [-D<argument>=<value>]...
DESCRIPTION
This tool allows you to create and update Cordova-BlackBerry-WebWorks projects.
You will want to run update after you have updated the framework source.
In other words, when you <git pull origin master>.
COMMANDS
help ............ Show this help menu.
ant, ant help
create .......... Create a new project
ant create PATH
ant create -Dproject.path="C:\dev\my_project"
update .......... Update an existing project
ant update PATH
ant update -Dproject.path="C:\dev\my_project"
dist ............ Create a Cordova distribution build
ant dist
version ......... Update Cordova version
ant version VERSION
ant version -Dvalue="1.0.0"
</echo>
</target>
</project>