forked from Ant-Grand/GrandUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
532 lines (488 loc) · 19.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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
<?xml version="1.0" encoding="UTF-8"?>
<project default="jars" name="grand-ui" basedir=".">
<property file="build-local.properties"/>
<property file="build.properties"/>
<property name="product.name" value="grand-ui"/>
<property name="product.fullname" value="${product.name}-${product.version}"/>
<property name="libdir" value="lib"/>
<property name="extlibdir" value="deps"/>
<property name="dlcachedir" value="cache"/>
<property name="classdir.main" value="bin/main"/>
<property name="distdir" value="dist"/>
<property name="srcdir.main" value="src/main"/>
<property name="confdir" value="etc"/>
<property name="jnlpdir" value="jnlp"/>
<property name="buildnum-file" value="etc/net/ggtools/grand/ui/buildnum.properties"/>
<property name="classdir.launcher" value="bin/launcher"/>
<property name="srcdir.launcher" value="src/launcher"/>
<property name="javadocdir" value="tmp/docs/api"/>
<property name="verbose-get" value="false"/>
<condition property="isLinux">
<os name="Linux"/>
</condition>
<condition property="isWin32">
<os family="windows"/>
</condition>
<condition property="isMacOS">
<os family="mac"/>
</condition>
<macrodef name="getjar" description="Download a jar to a the extlib directory">
<attribute name="dest"/>
<attribute name="url"/>
<sequential>
<get dest="${dlcachedir}/@{dest}" verbose="${verbose-get}" usetimestamp="true" ignoreerrors="true" src="@{url}"/>
<copy file="${dlcachedir}/@{dest}" todir="${extlibdir}" preservelastmodified="true"/>
</sequential>
</macrodef>
<macrodef name="get-extract-zip">
<attribute name="dest"/>
<attribute name="url"/>
<attribute name="libdir" default="${extlibdir}"/>
<element name="select" optional="yes"/>
<sequential>
<get dest="${dlcachedir}/@{dest}.zip" verbose="${verbose-get}" usetimestamp="true" ignoreerrors="true" src="@{url}"/>
<delete dir="${dlcachedir}/@{dest}"/>
<mkdir dir="${dlcachedir}/@{dest}"/>
<unzip dest="${dlcachedir}/@{dest}" src="${dlcachedir}/@{dest}.zip">
<select/>
</unzip>
<mkdir dir="@{libdir}"/>
<copy todir="@{libdir}" flatten="true" includeemptydirs="no" preservelastmodified="true">
<fileset dir="${dlcachedir}/@{dest}"/>
</copy>
</sequential>
</macrodef>
<macrodef name="get-extract-tgz">
<attribute name="dest"/>
<attribute name="url"/>
<attribute name="libdir" default="${extlibdir}"/>
<element name="select" optional="yes"/>
<sequential>
<get dest="${dlcachedir}/@{dest}.tgz" verbose="${verbose-get}" usetimestamp="true" ignoreerrors="true" src="@{url}"/>
<delete dir="${dlcachedir}/@{dest}"/>
<mkdir dir="${dlcachedir}/@{dest}"/>
<untar compression="gzip" dest="${dlcachedir}/@{dest}" src="${dlcachedir}/@{dest}.tgz">
<select/>
</untar>
<mkdir dir="@{libdir}"/>
<copy todir="@{libdir}" flatten="true" includeemptydirs="no" preservelastmodified="true">
<fileset dir="${dlcachedir}/@{dest}"/>
</copy>
</sequential>
</macrodef>
<selector id="src-dist-selector">
<or>
<filename name="src/**"/>
<filename name="etc/**"/>
<filename name="README.txt"/>
<filename name="LICENSE"/>
<filename name="COPYING"/>
<filename name="LICENSE-Graphviz.txt"/>
<filename name="cpl-v10.html"/>
<filename name="scripts/**"/>
<filename name="build.xml"/>
<filename name="build.properties"/>
</or>
</selector>
<patternset id="get-rcp-patterns">
<!--
<include name="**/org.eclipse.core.runtime_${eclipse.core.version}*.jar"/>
See http://wiki.eclipse.org/index.php/JFace#Using_JFace_outside_the_Eclipse_platform
-->
<include name="**/org.eclipse.equinox.common_${eclipse.equinox.version}*.jar"/>
<include name="**/org.eclipse.core.commands_${eclipse.commands.version}*.jar"/>
<include name="**/org.eclipse.ui.workbench_${eclipse.workbench.version}*.jar"/>
<include name="**/org.eclipse.osgi_${eclipse.core.version}*.jar"/>
<include name="**/org.eclipse.jface_${eclipse.core.version}*.jar"/>
<include name="**/com.ibm.icu_${icu.version}*.jar"/>
<include name="**/org.eclipse.swt.${swt.archive.tag}_${swt.version}.jar"/>
</patternset>
<target name="javadoc" description="Generates javadoc" depends="jars">
<mkdir dir="${javadocdir}"/>
<tstamp>
<format pattern="2004-yyyy" property="year"/>
</tstamp>
<property name="copyright" value="Copyright &copy; ggTools. All Rights Reserved."/>
<property name="title" value="Grand UI"/>
<javadoc use="true" private="true" destdir="${javadocdir}" author="true" version="true" sourcepath="src/main" packagenames="net.ggtools.grand.*">
<classpath>
<fileset dir="${libdir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${extlibdir}">
<include name="*.jar"/>
</fileset>
</classpath>
</javadoc>
</target>
<target name="make.keystore" if="keystore.dn" description="Creates a self-signed keystore for testing">
<fail>
<condition>
<or>
<not><isset property="keystore.alias"/></not>
<not><isset property="keystore.password"/></not>
<available file="${keystore.location}" type="file"/>
</or>
</condition>
</fail>
<exec executable="keytool">
<arg line="-genkey -alias ${keystore.alias} -keyalg RSA -keysize 2048"/>
<arg value="-keystore"/>
<arg file="${keystore.location}"/>
<arg line="-keypass ${keystore.password} -storepass ${keystore.password} -dname"/>
<arg value="${keystore.dn}"/>
</exec>
</target>
<target name="dist" depends="deploy,bin-dist,src-dist" description="Create source and binary distributions"/>
<!-- =================================
target: deploy
================================= -->
<target name="deploy" depends="clean,jars,get-alien-swt" description="Deploys the application to be used with Java Web Start.">
<fail message="You must define jnlp.deploydir" unless="jnlp.deploydir"/>
<copy tofile="${jnlp.deploydir}/${product.name}.jar" file="${libdir}/${product.fullname}.jar"/>
<copy tofile="${jnlp.deploydir}/${product.name}-launcher.jar" file="${libdir}/${product.fullname}-launcher.jar"/>
<copy todir="${jnlp.deploydir}">
<fileset dir="${extlibdir}">
<exclude name="*swt*.*"/>
<exclude name="**/*.so"/>
<exclude name="**/*.dll"/>
<exclude name="**/*.jnilib"/>
</fileset>
<fileset dir="${jnlpdir}">
<exclude name="*.jnlp"/>
</fileset>
</copy>
<!-- Substitute the tokens in the jnlp files -->
<copy todir="${jnlp.deploydir}">
<fileset dir="${jnlpdir}">
<include name="*.jnlp"/>
</fileset>
<filterset>
<filter token="ECLIPSE_VERSION" value="${eclipse.core.version}"/>
<filter token="CODEBASE" value="${jnlp.codebase}"/>
<filter token="TITLE" value="${jnlp.title}"/>
<filter token="WIN32_SWT_LIB" value="${jnlp.win32.swt-lib}"/>
<filter token="LINUX_SWT_LIB" value="${jnlp.linux.swt-lib}"/>
<filter token="MACOS_SWT_LIB" value="${jnlp.macos.swt-lib}"/>
</filterset>
</copy>
<copy todir="${jnlp.deploydir}/${dist.nativedir}">
<fileset dir="${extlibdir}">
<include name="*swt*.*"/>
<exclude name="**/*.so"/>
<exclude name="**/*.dll"/>
<exclude name="**/*.jnilib"/>
</fileset>
</copy>
<fail message="keystore.location must be defined" unless="keystore.location"/>
<fail message="keystore.alias must be defined" unless="keystore.alias"/>
<fail message="keystore.password must be defined" unless="keystore.password"/>
<signjar keystore="${keystore.location}" alias="${keystore.alias}" storepass="${keystore.password}" lazy="yes">
<fileset dir="${jnlp.deploydir}">
<include name="**/*.jar"/>
</fileset>
</signjar>
</target>
<target name="src-dist">
<mkdir dir="${distdir}"/>
<tar destfile="${distdir}/${product.fullname}-src.tar.gz" compression="gzip">
<tarfileset dir="." prefix="${product.fullname}-src">
<selector refid="src-dist-selector"/>
</tarfileset>
</tar>
<zip destfile="${distdir}/${product.fullname}-src.zip">
<zipfileset dir="." prefix="${product.fullname}-src">
<selector refid="src-dist-selector"/>
</zipfileset>
</zip>
</target>
<target name="bin-dist" depends="clean,jars,get-alien-swt">
<mkdir dir="${distdir}"/>
<!-- Prepare for bin distribution -->
<delete dir="tmp"/>
<mkdir dir="tmp/${product.fullname}"/>
<copy tofile="tmp/${product.fullname}/lib/grand-ui.jar" file="${libdir}/${product.fullname}.jar"/>
<copy tofile="tmp/${product.fullname}/grand-ui-launcher.jar" file="${libdir}/${product.fullname}-launcher.jar"/>
<copy todir="tmp/${product.fullname}/lib">
<fileset dir="${extlibdir}">
<exclude name="*swt*.*"/>
</fileset>
</copy>
<copy todir="tmp/${product.fullname}/lib/${dist.nativedir}">
<fileset dir="${extlibdir}">
<include name="*swt*.*"/>
<exclude name="swt-lib.jar"/>
</fileset>
</copy>
<copy todir="tmp/${product.fullname}" flatten="true">
<fileset dir=".">
<include name="README.txt"/>
<include name="LICENSE"/>
<include name="COPYING"/>
<include name="LICENSE-Graphviz.txt"/>
<include name="cpl-v10.html"/>
<include name="scripts/*"/>
</fileset>
</copy>
<chmod perm="755">
<fileset dir="tmp/${product.fullname}">
<include name="*.jar"/>
<include name="grand-ui"/>
</fileset>
</chmod>
<tar destfile="${distdir}/${product.fullname}.tar.gz" compression="gzip">
<tarfileset dir="tmp/${product.fullname}" prefix="${product.fullname}" mode="755">
<include name="grand-ui"/>
<include name="grand-ui.jar"/>
</tarfileset>
<tarfileset dir="tmp/${product.fullname}" prefix="${product.fullname}">
<exclude name="grand-ui"/>
<exclude name="grand-ui.jar"/>
</tarfileset>
</tar>
<zip destfile="${distdir}/${product.fullname}.zip" basedir="tmp" includes="${product.fullname}/**"/>
</target>
<target name="jars" depends="compile.java,incbuildnum" description="Create the application jar(s)">
<mkdir dir="${libdir}"/>
<jar destfile="${libdir}/${product.fullname}.jar" index="true">
<fileset dir="${classdir.main}"/>
<fileset dir="${confdir}"/>
<manifest>
<attribute name="Main-Class" value="net.ggtools.grand.ui.Application"/>
</manifest>
</jar>
<jar destfile="${libdir}/${product.fullname}-launcher.jar" index="true">
<fileset dir="${classdir.launcher}"/>
<!--fileset dir="${confdir}" /-->
<manifest>
<attribute name="Main-Class" value="net.ggtools.grand.ui.launcher.Launcher"/>
</manifest>
</jar>
</target>
<target name="compile.java" depends="init" description="Compile the java source files">
<mkdir dir="${classdir.main}"/>
<javac srcdir="${srcdir.main}" destdir="${classdir.main}" debug="true" optimize="true" includeantruntime="false" source="1.5" target="1.5">
<classpath>
<path refid="ext-libs"/>
</classpath>
</javac>
<mkdir dir="${classdir.launcher}"/>
<javac srcdir="${srcdir.launcher}" destdir="${classdir.launcher}" debug="true" optimize="true" includeantruntime="false" source="1.5" target="1.5">
<classpath>
<path refid="ext-libs"/>
</classpath>
</javac>
</target>
<target name="incbuildnum" depends="setup-svn-macros" unless="noincbuildnum">
<svn-update file="${buildnum-file}"/>
<propertyfile file="${buildnum-file}">
<entry key="build.date" type="date" value="now" pattern="yyyy-MM-dd"/>
<entry key="build.time" type="date" value="now" pattern="HH:mm:ss"/>
<entry key="build.number" type="int" operation="+" default="0"/>
<entry key="build.version.string" type="string" value="${product.version}"/>
</propertyfile>
<property file="${buildnum-file}"/>
<echo message="build number set to ${build.number}"/>
<svn-commit message="Setting buildnum to ${build.number} for ${product.name}" file="${buildnum-file}"/>
</target>
<target name="init" depends="get-deps">
<path id="ext-libs">
<fileset dir="${extlibdir}">
<include name="**/*.jar"/>
</fileset>
</path>
</target>
<target name="setup-svn-macros" depends="setup-svn-macros-svn,setup-svn-macros-svk"/>
<target name="setup-svn-macros-svn" unless="USE_SVK">
<taskdef resource="svntask.properties"/>
<macrodef name="svn-update">
<attribute name="file"/>
<sequential>
<svn>
<update file="@{file}"/>
</svn>
</sequential>
</macrodef>
<macrodef name="svn-commit">
<attribute name="file"/>
<attribute name="message"/>
<sequential>
<svn>
<commit file="@{file}" message="@{message}"/>
</svn>
</sequential>
</macrodef>
</target>
<target name="setup-svn-macros-svk" if="USE_SVK">
<macrodef name="svn-update">
<attribute name="file"/>
<sequential>
<exec executable="svk">
<arg line="update @{file}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="svn-commit">
<attribute name="file"/>
<attribute name="message"/>
<sequential>
<exec executable="svk">
<arg line="commit -m '@{message}' @{file}"/>
</exec>
</sequential>
</macrodef>
</target>
<target name="clean" depends="clean.dist,clean.deps" description="Remove intermediate files but not external libs">
<delete dir="${libdir}"/>
<delete dir="${classdir.main}"/>
<delete dir="${classdir.launcher}"/>
</target>
<target name="clean.deps" description="Clean the dependencies directory">
<delete dir="${extlibdir}"/>
</target>
<target name="clean.dist" description="Clean the dist directory">
<delete dir="${distdir}"/>
</target>
<target name="real.clean" depends="clean" description="Remove intermediate files ant external libs">
<delete dir="${dlcachedir}"/>
</target>
<target name="get-deps" depends="get-extjars,get-rcp,get-draw2d" description="Get and prepare the external libraries"/>
<target name="get-extjars" depends="prepare-download" unless="noget">
<getjar dest="ant.jar" url="${url.ant.jar}"/>
<getjar dest="ant-launcher.jar" url="${url.ant-launcher.jar}"/>
<getjar dest="commons-logging.jar" url="${url.commons-logging.jar}"/>
<getjar dest="blacksun-util.jar" url="${url.blacksun-util.jar}"/>
<getjar dest="jzgraph.jar" url="${url.jzgraph.jar}"/>
<getjar dest="oro.jar" url="${url.oro.jar}"/>
<getjar dest="grand.jar" url="${url.grand.jar}"/>
</target>
<target name="get-rcp-zip">
<fail unless="url.eclipse.rcp" message="url.eclipse.rcp should be defined"/>
<get-extract-zip dest="rcp" url="${url.eclipse.rcp}">
<select>
<patternset refid="get-rcp-patterns"/>
</select>
</get-extract-zip>
</target>
<target name="get-rcp-tgz">
<fail unless="url.eclipse.rcp" message="url.eclipse.rcp should be defined"/>
<get-extract-tgz dest="rcp" url="${url.eclipse.rcp}">
<select>
<patternset refid="get-rcp-patterns"/>
</select>
</get-extract-tgz>
</target>
<target name="get-rcp" depends="set-swt-properties" unless="noget">
<antcall target="${get-rcp-target}" inheritall="true" inheritrefs="true"/>
<move file="${extlibdir}/org.eclipse.swt.${swt.archive.tag}_${swt.version}.jar" tofile="${extlibdir}/swt.jar"/>
<!-- extract dll from the bundle jar -->
<unjar src="${extlibdir}/swt.jar" dest="${dlcachedir}/rcp">
<patternset>
<include name="**/*.so"/>
<include name="**/*.dll"/>
<include name="**/*.jnilib"/>
</patternset>
</unjar>
<copy todir="${extlibdir}" preservelastmodified="true" flatten="true">
<fileset dir="${dlcachedir}/rcp">
<include name="**/*.so"/>
<include name="**/*.dll"/>
<include name="**/*.jnilib"/>
</fileset>
</copy>
<!-- Creates a swt-lib.jar for JNLP -->
<delete dir="tmp"/>
<mkdir dir="tmp/rcp"/>
<copy todir="tmp/rcp" preservelastmodified="true">
<fileset dir="${extlibdir}">
<include name="*.so"/>
<include name="*.dll"/>
<include name="*.jnilib"/>
</fileset>
</copy>
<jar destfile="${dlcachedir}/swt-lib.jar" basedir="tmp/rcp" index="true"/>
<copy todir="${extlibdir}" file="${dlcachedir}/swt-lib.jar" preservelastmodified="true"/>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: get-alien-swt
- - - - - - - - - - - - - - - - - -->
<target name="get-alien-swt" depends="set-swt-properties">
<get-swt url="${url.eclipse.alien.swt}" name="${dist.aliendir}"/>
</target>
<macrodef name="get-swt">
<attribute name="url"/>
<attribute name="name"/>
<sequential>
<get-extract-zip dest="alien-swt-@{name}" url="@{url}" libdir="${extlibdir}/@{name}">
<select>
<patternset>
<include name="**/swt*.jar"/>
<include name="**/swt*.dll"/>
<include name="**/libswt*.so"/>
<include name="**/libswt*.jnilib"/>
</patternset>
</select>
</get-extract-zip>
<!-- Creates a swt-lib.jar for JNLP -->
<delete dir="tmp"/>
<mkdir dir="tmp/alien-swt-@{name}"/>
<copy todir="tmp/alien-swt-@{name}" preservelastmodified="true" flatten="true">
<fileset dir="${dlcachedir}/alien-swt-@{name}">
<include name="**/*.so"/>
<include name="**/*.dll"/>
<include name="**/*.jnilib"/>
</fileset>
</copy>
<jar destfile="${dlcachedir}/swt-lib-alien-@{name}.jar" basedir="tmp/alien-swt-@{name}" index="true"/>
<copy tofile="${extlibdir}/@{name}/swt-lib.jar" file="${dlcachedir}/swt-lib-alien-@{name}.jar" preservelastmodified="true"/>
<delete dir="tmp/alien-swt-@{name}"/>
</sequential>
</macrodef>
<target name="get-draw2d" unless="noget">
<get-extract-zip dest="gef" url="${url.gef}">
<select>
<patternset>
<include name="**/org.eclipse.draw2d_${eclipse.core.version}*.jar"/>
</patternset>
</select>
</get-extract-zip>
</target>
<target name="prepare-download">
<mkdir dir="${extlibdir}"/>
<mkdir dir="${dlcachedir}"/>
</target>
<target name="set-swt-properties" depends="set-swt-properties-linux,set-swt-properties-win32,set-swt-properties-macos" description="Set the swt properties according to the current os"/>
<target name="set-swt-properties-linux" if="isLinux">
<property name="url.eclipse.rcp" value="${url.eclipse.rcp}"/>
<property name="url.eclipse.alien.swt" value="${url.eclipse.swt.linux}"/>
<property name="dist.nativedir" value="linux-gtk"/>
<property name="dist.aliendir" value="linux-gtk-32-bit"/>
<property name="get-rcp-target" value="get-rcp-tgz"/>
<property name="swt.archive.tag" value="gtk.linux.x86_64"/>
<property name="jnlp.linux.swt-lib" value="swt-lib"/>
<property name="jnlp.win32.swt-lib" value="swt-lib"/>
<property name="jnlp.macos.swt-lib" value="swt-lib"/>
</target>
<target name="set-swt-properties-win32" if="isWin32">
<property name="url.eclipse.rcp" value="${url.eclipse.rcp}"/>
<property name="url.eclipse.alien.swt" value="${url.eclipse.swt.windows}"/>
<property name="dist.nativedir" value="win32"/>
<property name="dist.aliendir" value="win32-32-bit"/>
<property name="get-rcp-target" value="get-rcp-zip"/>
<property name="swt.archive.tag" value="win32.win32.x86_64"/>
<property name="jnlp.linux.swt-lib" value="swt-lib"/>
<property name="jnlp.win32.swt-lib" value="swt-lib"/>
<property name="jnlp.macos.swt-lib" value="swt-lib"/>
</target>
<target name="set-swt-properties-macos" if="isMacOS">
<property name="url.eclipse.rcp" value="${url.eclipse.rcp}"/>
<property name="url.eclipse.alien.swt" value="${url.eclipse.swt.macosx}"/>
<property name="dist.nativedir" value="macosx"/>
<property name="dist.aliendir" value="macos-32-bit"/>
<property name="get-rcp-target" value="get-rcp-zip"/>
<property name="swt.archive.tag" value="cocoa.macosx.x86_64"/>
<property name="jnlp.linux.swt-lib" value="swt-lib"/>
<property name="jnlp.win32.swt-lib" value="swt-lib"/>
<property name="jnlp.macos.swt-lib" value="swt-lib"/>
</target>
</project>