forked from jsplumb/jsplumb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
422 lines (373 loc) · 16.1 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<?xml version="1.0"?>
<project default="build">
<path id="yuicompressor.classpath">
<fileset dir="./lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="yui.minify">
<java jar="./lib/yuicompressor-2.4.2.jar" fork="true" output="${output}">
<arg value="${input}"/>
<classpath>
<path refid="yuicompressor.classpath"/>
</classpath>
</java>
</target>
<!-- ant-contrib taskdefs -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="./lib/ant-contrib-0.6.jar"/>
</classpath>
</taskdef>
<!-- main build dir, inside which we have one dir per build number -->
<property name="build.dir" value="./build"/>
<!-- create final version number -->
<propertyregex property="final.version"
input="${version}"
regexp="[0-9]+\.[0-9]+\.[0-9]+"
select="\0"
casesensitive="false" />
<!-- js input directory -->
<property name="dir" value="./js/${final.version}/"/>
<!-- input demo directory -->
<property name="demo.dir" value="./demo"/>
<!-- output directory -->
<property name="output.dir" value="${build.dir}/${final.version}"/>
<!-- output JS directory -->
<property name="output.js.dir" value="${build.dir}/${final.version}/js"/>
<!-- output demo directory -->
<property name="output.demo.dir" value="${build.dir}/${final.version}/demo"/>
<!-- output demo js directory -->
<property name="output.demo.js.dir" value="${build.dir}/${final.version}/demo/js"/>
<!-- output tests directory -->
<property name="output.tests.dir" value="${build.dir}/${final.version}/tests"/>
<!--
fails the build if no "version" parameter supplied.
-->
<target name="checkForVersion" unless="version">
<fail message="You must supply the version to bundle, eg. ant -Dversion=x.y.c-RCn"/>
</target>
<!-- fails if the desired build dir already exists and force was not specified on the command line. -->
<target name="checkForExistingBuildDir" unless="force">
<if>
<available file="${output.dir}" type="dir"/>
<then>
<echo>Output directory already exists and "-Dforce=true" was not specified - exiting.</echo>
<fail message="output directory already exists"/>
</then>
</if>
</target>
<!-- creates the output dir, if necessary -->
<target name="init" depends="checkForExistingBuildDir,checkForVersion">
<!-- this will fail silently if the dir already exists; that's ok. it's because this is the first build this user has run. -->
<mkdir dir="${build.dir}"/>
<!-- but these should not already exist; we will have bailed before here if that's the case, unless the user
specified the '-Dforce=true' argument on the command line -->
<delete dir="${output.dir}"/>
<mkdir dir="${output.dir}"/>
<mkdir dir="${output.dir}/doc"/>
<mkdir dir="${output.js.dir}"/>
<mkdir dir="${output.demo.dir}"/>
<mkdir dir="${output.tests.dir}"/>
<echo/>
<echo>Building Version : ${final.version} into directory ${output.dir}</echo>
</target>
<!--
concats a single library.
expects "library" parameter to be set.
-->
<target name="concatLibrary">
<echo>Concatenating ${library}</echo>
<concat destfile="${output.js.dir}/${library}.jsPlumb-${final.version}-all.js">
<filelist dir="${dir}" files="jsPlumb-util-${version}.js, jsPlumb-dom-adapter-${version}.js, jsPlumb-${version}.js,jsPlumb-anchors-${version}.js,jsPlumb-defaults-${version}.js,jsPlumb-connectors-statemachine-${version}.js,jsPlumb-connectors-flowchart-${version}.js, jsPlumb-renderers-vml-${version}.js, jsPlumb-renderers-svg-${version}.js, jsPlumb-renderers-canvas-${version}.js, ${library}.jsPlumb-${version}.js, ../lib/jsBezier-0.5-min.js"/>
</concat>
</target>
<target name="concatLibraryNoCanvas">
<echo>Concatenating ${library} without canvas renderer</echo>
<concat destfile="${output.js.dir}/${library}.jsPlumb-${final.version}-nocanvas-all.js">
<filelist dir="${dir}" files="jsPlumb-util-${version}.js, jsPlumb-dom-adapter-${version}.js, jsPlumb-${version}.js,jsPlumb-anchors-${version}.js,jsPlumb-defaults-${version}.js,jsPlumb-connectors-statemachine-${version}.js,jsPlumb-connectors-flowchart-${version}.js, jsPlumb-renderers-vml-${version}.js, jsPlumb-renderers-svg-${version}.js, ${library}.jsPlumb-${version}.js, ../lib/jsBezier-0.5-min.js"/>
</concat>
</target>
<!-- minifies a concatenated library -->
<target name="minLibrary" depends="concatLibrary">
<echo>Minifying ${library}</echo>
<antcall target="yui.minify">
<param name="input" value="${output.js.dir}/${library}.jsPlumb-${final.version}-all.js"/>
<param name="output" value="${output.js.dir}/${library}.jsPlumb-${final.version}-all-min.js"/>
</antcall>
</target>
<!-- minifies a concatenated library -->
<target name="minLibraryNoCanvas" depends="concatLibraryNoCanvas">
<echo>Minifying ${library} without canvas renderer</echo>
<antcall target="yui.minify">
<param name="input" value="${output.js.dir}/${library}.jsPlumb-${final.version}-nocanvas-all.js"/>
<param name="output" value="${output.js.dir}/${library}.jsPlumb-${final.version}-nocanvas-all-min.js"/>
</antcall>
</target>
<!--
generates minified and concatenated scripts for supported libraries.
-->
<target name="minAll">
<antcall target="minLibrary">
<param name="library" value="jquery"/>
</antcall>
<antcall target="minLibrary">
<param name="library" value="mootools"/>
</antcall>
<antcall target="minLibrary">
<param name="library" value="yui"/>
</antcall>
<antcall target="minLibraryNoCanvas">
<param name="library" value="jquery"/>
</antcall>
<antcall target="minLibraryNoCanvas">
<param name="library" value="mootools"/>
</antcall>
<antcall target="minLibraryNoCanvas">
<param name="library" value="yui"/>
</antcall>
</target>
<!-- replaces JS imports in HTML files with minified versions and with production links to dependencies -->
<target name="html">
<echo>Replacing Javascript imports for ${library}</echo>
<!-- replace JS dependency with the prod version -->
<replaceregexp>
<regexp pattern="(<!-- DEP.*>.*\n)(.*\n)*(.*/DEP -->)"/>
<substitution expression="${dependencies}"/>
<fileset dir="${output.demo.dir}/${libraryDir}">
<include name="*.html"/>
</fileset>
</replaceregexp>
<!-- replace all JS with the minified file -->
<replaceregexp>
<regexp pattern="(<!-- JS.*>.*\n)(.*\n)*(.*/JS -->)"/>
<substitution expression="<script type='text/javascript' src='../js/${library}.jsPlumb-${final.version}-all-min.js'></script>"/>
<fileset dir="${output.demo.dir}/${libraryDir}">
<include name="*.html"/>
</fileset>
</replaceregexp>
</target>
<!-- copies the demos and replaces their JS imports with final versions -->
<target name="demo">
<echo>Processing demo code...</echo>
<copy todir="${output.demo.dir}">
<fileset dir="${demo.dir}"/>
</copy>
<!-- copy built JS -->
<copy todir="${output.demo.js.dir}">
<fileset dir="${output.js.dir}"/>
</copy>
<!-- replace dev JS imports with final versions -->
<antcall target="html">
<param name="libraryDir" value="jquery"/>
<param name="library" value="jquery"/>
<param name="dependencies" value="<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js'></script><script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js'></script><script type='text/javascript' src='../js/jquery.ui.touch-punch.min.js'></script>"/>
</antcall>
<antcall target="html">
<param name="libraryDir" value="mootools"/>
<param name="library" value="mootools"/>
<param name="dependencies" value="<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js'></script>"/>
</antcall>
<antcall target="html">
<param name="libraryDir" value="yui3"/>
<param name="library" value="yui"/>
</antcall>
</target>
<!-- copies the jsPlumb documentation into the build area -->
<target name="copy-documentation">
<echo>Copying documentation...</echo>
<copy todir="${output.dir}/demo/doc">
<fileset dir="./demo/doc">
<include name="*.html"/>
<include name="*.css"/>
</fileset>
</copy>
<copy todir="${output.dir}/demo/doc">
<fileset dir="./demo/doc">
<include name="*.html"/>
<include name="*.css"/>
</fileset>
</copy>
</target>
<!-- writes the final version of JS into the copies of test html, files replacing the dev imports -->
<target name="update-tests-js">
<replaceregexp>
<regexp pattern="(<!-- JS.*>.*\n)(.*\n)*(.*/JS -->)"/>
<substitution expression="<script type='text/javascript' src='../js/${library}.jsPlumb-${final.version}-all-min.js'></script>"/>
<fileset dir="${output.tests.dir}">
<include name="*${library}.html"/>
<include name="*${library}-instance.html"/>
</fileset>
</replaceregexp>
<replaceregexp>
<regexp pattern="(<!-- TEST.*>.*\n)(.*\n)*(.*/TEST -->)"/>
<substitution expression="<script type='text/javascript' src='../js/jsPlumb-${final.version}-tests.js'></script>"/>
<fileset dir="${output.tests.dir}">
<include name="*${library}.html"/>
<include name="*${library}-instance.html"/>
</fileset>
</replaceregexp>
</target>
<!-- copies the tests directory into the build dir -->
<target name="copy-tests">
<copy todir="${output.js.dir}">
<fileset dir="js/${final.version}">
<include name="jsPlumb-${final.version}-tests.js"/>
</fileset>
</copy>
<copy todir="${output.tests.dir}">
<fileset dir="tests">
<include name="*.html"/>
<include name="*.css"/>
</fileset>
</copy>
<mkdir dir="${output.js.dir}/lib"/>
<copy todir="${output.js.dir}/lib">
<fileset dir="js/lib">
<include name="qunit.js"/>
</fileset>
</copy>
<!-- now replace the JS with minified ones! -->
<antcall target="update-tests-js">
<param name="library" value="jquery"/>
</antcall>
<antcall target="update-tests-js">
<param name="library" value="mootools"/>
</antcall>
<antcall target="update-tests-js">
<param name="library" value="yui"/>
</antcall>
</target>
<target name="doc-version" unless="final.version">
<fail message="You must supply the final version to build api docs from"/>
</target>
<!-- generates the API docs -->
<target name="docs" depends="doc-version">
<mkdir dir="js/TEMP"/>
<mkdir dir="js/TEMPOUT"/>
<copy todir="js/TEMP">
<fileset dir="build/${final.version}/js">
<include name="jquery.jsPlumb-${final.version}-all.js"/>
</fileset>
</copy>
<mkdir dir="apidocs"/>
<exec executable="naturaldocs">
<arg line="-i"/>
<arg path="js/TEMP"/>
<arg line="-o"/>
<arg line="HTML"/>
<arg line="js/TEMPOUT"/>
<arg line="-p"/>
<arg line="."/>
</exec>
<!-- replace the jquery.blah title stuff that apidocs comes up with -->
<replace dir="js/TEMPOUT" token="<wbr>"/>
<replace dir="js/TEMPOUT" token="jquery.jsPlumb-${final.version}-all.js" value="jsPlumb ${final.version}"/>
<!-- get a copy of the version number with dashes not dots -->
<propertyregex property="version.with.dashes"
input="${final.version}"
regexp="([0-9])\.([0-9])\.([0-9])"
replace="\1-\2-\3"/>
<!-- write the index file -->
<echo file="js/TEMPOUT/index.html" append="false"><html><head><meta http-equiv="Refresh" CONTENT="0; URL=./files/jquery-jsPlumb-${version.with.dashes}-all-js.html"></head></html></echo>
<delete dir="Data"/>
<delete dir="js/TEMP"/>
<delete>
<fileset dir="demo/apidocs">
<include name="**/*.html"/>
</fileset>
</delete>
<mkdir dir="demo/apidocs"/>
<copy todir="demo/apidocs">
<fileset dir="js/TEMPOUT">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="build/${final.version}/demo/apidocs">
<fileset dir="demo/apidocs">
<include name="**/*"/>
</fileset>
</copy>
<delete dir="js/TEMPOUT"/>
</target>
<!-- builds a version of jsplumb -->
<target name="build" depends="init">
<antcall target="minAll"/>
<antcall target="demo"/>
<antcall target="copy-documentation"/>
<antcall target="copy-tests"/>
</target>
<!-- builds a version of jsplumb and generates apidocs -->
<target name="build-all" depends="build">
<antcall target="docs"/>
</target>
<target name="new" unless="new">
<fail message="You must supply the new version, eg: ant -Dold=1.3.7 -Dnew=1.3.8"/>
</target>
<target name="old" unless="old">
<fail message="You must supply the old version, eg: ant -Dold=1.3.7 -Dnew=1.3.8"/>
</target>
<!-- creates/copies all the files needed for a new version -->
<target name="newversion" depends="old,new">
<propertyregex property="new.escaped"
input="${new}"
regexp="\."
replace="\\."/>
<propertyregex property="old.escaped"
input="${old}"
regexp="\."
replace="\\\."/>
<echo>${new.escaped}</echo>
<!-- create new js dir and copy previous version js into it -->
<mkdir dir="js/${new}"/>
<copy todir="js/${new}">
<fileset dir="js/${old}">
<include name="*.js"/>
</fileset>
<mapper type="regexp" from="(.*)${old.escaped}(.*)" to="\1${new.escaped}\2"/>
</copy>
<!-- create new dir in tests/archive and copy test html files in there -->
<mkdir dir="tests/archive/${old}"/>
<copy todir="tests/archive/${old}">
<fileset dir="tests">
<include name="*.html"/>
<include name="*.css"/>
</fileset>
</copy>
<!-- replace refs to old version in test html to new version -->
<replace file="tests/android-svg.html" token="${old}" value="${new}"/>
<replace file="tests/loadTestHarness.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-canvas-jquery-instance.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-canvas-jquery.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-canvas-mootools.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-svg-jquery-instance.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-svg-jquery.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-vml-jquery-instance.html" token="${old}" value="${new}"/>
<replace file="tests/qunit-vml-jquery.html" token="${old}" value="${new}"/>
<!-- create new archive dir for docs -->
<mkdir dir="demo/doc/archive/${old}"/>
<copy todir="demo/doc/archive/${old}">
<fileset dir="demo/doc">
<include name="*.html"/>
<include name="*.css"/>
</fileset>
</copy>
<replace file="demo/doc/content.html" token="${old}" value="${new}"/>
<replace file="demo/doc/usage.html" token="${old}" value="${new}"/>
<replace file="demo/doc/index.html" token="${old}" value="${new}"/>
<!-- replace refs to old version in demo html to new version -->
<replace dir="demo/jquery" token="${old}" value="${new}"/>
<replace dir="demo/yui3" token="${old}" value="${new}"/>
<replace dir="demo/mootools" token="${old}" value="${new}"/>
<!-- replace version number in code -->
<replace dir="js/${new}" token="${old}" value="${new}"/>
<!-- replace in README >
<replace file="README.md" token="latest version is ${old}" value="latest version is ${new}"/-->
</target>
<target name="upgrade-jsbezier" depends="old,new">
<!-- replace refs to old version in demo html to new version -->
<replace dir="demo/jquery" token="jsBezier-${old}-min.js" value="jsBezier-${new}-min.js"/>
<replace dir="demo/yui3" token="jsBezier-${old}-min.js" value="jsBezier-${new}-min.js"/>
<replace dir="demo/mootools" token="jsBezier-${old}-min.js" value="jsBezier-${new}-min.js"/>
</target>
</project>