forked from jsplumb/jsplumb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
338 lines (295 loc) · 11.8 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
<?xml version="1.0"?>
<project default="build">
<path id="yuicompressor.classpath">
<fileset dir="./ant">
<include name="*.jar"/>
</fileset>
</path>
<target name="yui.minify">
<java jar="./ant/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="./ant/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="./src/"/>
<!-- input demo directory -->
<property name="demo.dir" value="./demo"/>
<!-- output directory -->
<property name="output.dir" value="${build.dir}"/>
<!-- output JS directory -->
<property name="output.js.dir" value="${build.dir}/js"/>
<!-- output demo directory -->
<property name="output.demo.dir" value="${build.dir}/demo"/>
<!-- output demo js directory -->
<property name="output.demo.js.dir" value="${build.dir}/demo/js"/>
<!-- output tests directory -->
<property name="output.tests.dir" value="${build.dir}/tests"/>
<target name="checkForVersion">
<loadproperties srcFile="build.properties"/>
</target>
<!-- creates the output dir, if necessary -->
<target name="init" depends="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 : ${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.js, jsPlumb-dom-adapter.js, jsPlumb.js,jsPlumb-anchors.js,jsPlumb-endpoint.js,jsPlumb-connection.js,jsPlumb-defaults.js,jsPlumb-connectors-statemachine.js,jsPlumb-connectors-flowchart.js, jsPlumb-renderers-vml.js, jsPlumb-renderers-svg.js, ${library}.jsPlumb.js, ../lib/jsBezier-0.6-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>
<!--
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>
</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">
<!-- copy a jsplumb version into require js sample -->
<copy tofile="${demo.dir}/requirejs/scripts/jsplumb.js" file="${output.js.dir}/jquery.jsPlumb-${final.version}-all.js"/>
<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>
<!-- 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"/>
<include name="loadTestHarness.html"/>
</fileset>
</replaceregexp>
</target>
<!-- copies the tests directory into the build dir -->
<target name="copy-tests">
<copy todir="${output.js.dir}">
<fileset dir="src">
<include name="jsPlumb-tests.js"/>
</fileset>
</copy>
<copy todir="${output.tests.dir}">
<fileset dir="tests">
<include name="*.html"/>
<include name="*.css"/>
<include name="*.js"/>
</fileset>
</copy>
<mkdir dir="${output.js.dir}/lib"/>
<copy todir="${output.js.dir}/lib">
<fileset dir="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>
<!-- copies the lib directory to build -->
<target name="copy-lib">
<mkdir dir="${output.dir}/lib"/>
<copy todir="${output.dir}/lib">
<fileset dir="lib">
<include name="*.*"/>
</fileset>
</copy>
</target>
<!-- copies the font directory to build -->
<target name="copy-font">
<mkdir dir="${output.dir}/font"/>
<copy todir="${output.dir}/font">
<fileset dir="demo/font">
<include name="*.*"/>
</fileset>
</copy>
</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="TEMP"/>
<mkdir dir="TEMPOUT"/>
<copy todir="TEMP">
<fileset dir="src">
<include name="jsPlumb-apidoc.js"/>
</fileset>
</copy>
<mkdir dir="apidocs"/>
<exec executable="naturaldocs">
<arg line="-i"/>
<arg path="TEMP"/>
<arg line="-o"/>
<arg line="HTML"/>
<arg line="TEMPOUT"/>
<arg line="-p"/>
<arg line="."/>
</exec>
<!-- replace the jquery.blah title stuff that apidocs comes up with -->
<!-- TODO this will have also changed -->
<replace dir="TEMPOUT" token="<wbr>"/>
<replace dir="TEMPOUT" token="jsPlumb-apidoc-js.html" value="jsPlumb-${final.version}-apidoc.html"/>
<!-- rename apidoc main file -->
<move file="TEMPOUT/files/jsPlumb-apidoc-js.html" tofile="TEMPOUT/files/jsPlumb-${final.version}-apidoc.html"/>
<!-- write the index file -->
<echo file="TEMPOUT/index.html" append="false"><html><head><meta http-equiv="Refresh" CONTENT="0; URL=./files/jsPlumb-${final.version}-apidoc.html"></head></html></echo>
<delete dir="Data"/>
<delete dir="TEMP"/>
<delete>
<fileset dir="apidocs">
<include name="**/*.html"/>
</fileset>
</delete>
<mkdir dir="apidocs"/>
<copy todir="apidocs">
<fileset dir="TEMPOUT">
<include name="**/*"/>
</fileset>
</copy>
<copy todir="build/apidocs">
<fileset dir="apidocs">
<include name="**/*"/>
</fileset>
</copy>
<delete dir="TEMPOUT"/>
</target>
<!-- builds a version of jsplumb -->
<target name="build" depends="init">
<antcall target="minAll"/>
<antcall target="demo"/>
<antcall target="copy-tests"/>
<antcall target="copy-lib"/>
<antcall target="copy-font"/>
</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 -Dnew=1.4.1"/>
</target>
<target name="old" unless="old">
<fail message="You must supply the old version, eg: ant -Dold=0.6"/>
</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>
<!-- 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="src" token="${old}" value="${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}.js" value="jsBezier-${new}.js"/>
<replace dir="demo/yui3" token="jsBezier-${old}.js" value="jsBezier-${new}.js"/>
<replace dir="demo/mootools" token="jsBezier-${old}.js" value="jsBezier-${new}.js"/>
</target>
</project>