File: build.xml

package info (click to toggle)
starjava-topcat 4.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 22,216 kB
  • sloc: java: 65,710; xml: 29,046; sh: 73; makefile: 16
file content (1703 lines) | stat: -rw-r--r-- 67,017 bytes parent folder | download
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
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
<?xml version="1.0"?>

<!--
 !   TOPCAT build file
 !
 !   This file describes how to build and install {Package}
 !   from a source and binary release. {Package} is an application
 !   package, i.e. provides user-level commands and interfaces, as
 !   well as a programming API.
 !
 !   The main targets are:
 !
 !      build            -> compiles the source code
 !      clean            -> cleans up build and dist products
 !      deinstall        -> undo the install target
 !      dist             -> creates the local binary distribution
 !      export           -> creates the full distribution archives
 !      export-runonly   -> creates the runonly distribution archives
 !      export-source    -> creates the source distribution archives
 !      install          -> installs the distribution
 !      install-runonly  -> installs a runonly distribution
 !      jars             -> creates the package jar file(s)
 !      javadocs         -> creates the package API documentation
 !      javadoc-sources  -> make source files for release API documention
 !      test             -> runs JUnit test cases
 !
 !   Targets specific to TOPCAT:
 !      build-standalone -> builds topcat-full.jar, topcat-lite.jar
 !      docs-pdf         -> builds sun253.pdf
 !
 !   Authors:
 !      Peter W. Draper (17-SEP-2002)
 !
 !   Version:
 !      $Id$
 !
 !-->

<project name="Build file for TOPCAT" default="build" basedir=".">
  <!-- Properties will also be set for all environment variables
   !   (PATH becomes "env.PATH"), generally not a good
   !   idea as names are OS dependent -->
  <property environment="env"/>

  <!--
   !  =================
   !  Global Properties
   !  =================
   !-->

  <!-- Directory for the Starlink installation (usually /star/java)-->
  <property name="star.dir" value="/usr/share/java"/>

  <!-- Directory to install into (install target, usually /star/java)-->
  <property name="star.install" value="${star.dir}"/>

  <!-- Directory that contains the Starlink jar tree -->
  <property name="star.jar.dir" value="${star.dir}"/>

  <!-- Directory that contains the locally built sources (usually
   !   /star/java/source for full distribution) -->
  <property name="star.build.dir" value="${basedir}/../"/>

  <!-- Directory that any archives should be placed into. The local
   !   directory by default -->
  <property name="star.archive.dir" value="${basedir}"/>

  <!-- URL and package-list for linking against full Java docs -->
  <property name="javaapi.url" value="http://docs.oracle.com/javase/6/docs/api/"/>
  <property name="javaapi.lis" value="${star.build.dir}/src/docs/javaapi/"/>

  <!--
   !  ================
   !  Local Properties
   !  ================
   !-->

  <!-- Define the package name and current versions -->
  <property name="Name" value="Starjava TOPCAT"/>
  <property name="name" value="starlink-topcat"/>
  <property name="version" value="4.6-2"/>

  <!-- The Java package name -->
  <property name="package.name" value="uk.ac.starlink.topcat"/>

  <!-- Compilation options -->
  <property name="debug" value="true"/>
  <property name="deprecation" value="false"/>
  <property name="optimize" value="true"/>
  <property name="source.version" value="1.5"/>

  <!-- Extra task options, if any -->
  <property name="chmod.fail" value="false"/>

  <!-- JUnit test options -->
  <property name="junit.fork" value="false"/>
  <property name="junit.filtertrace" value="on"/>
  <property name="junit.summary" value="no"/>
  <property name="junit.assertions" value="-enableassertions"/>

  <!-- Directory containing the package source -->
  <property name="src.dir" value="${basedir}/src"/>

  <!-- Directory containing the java source (top of the namespace)-->
  <property name="java.dir" value="${src.dir}/main"/>

  <!-- Directory containing miscellaneous docs -->
  <property name="user.doc" value="sun253"/>
  <property name="src.docs" value="${src.dir}/docs"/>
  <property name="xdoc.etc" value="${src.dir}/etc/xdoc"/>
  <property name="gbin.docs" value="${star.dir}/docs/gbin"/>

  <!-- Directory containing any script required to execute or setup package-->
  <property name="script.dir" value="${src.dir}/script"/>

  <!-- Directory containing any third-party jars that should be
   !   distributed (normally these would belong in a proper package)-->
  <property name="src.jars.dir" value="${src.dir}/lib"/>
  <mkdir dir="${src.jars.dir}"/>

  <!-- Directory containing any JNI source code -->
  <property name="src.jni.dir" value="${src.dir}/jni"/>

  <!-- Directory for demo data -->
  <property name="src.etc" value="${src.dir}/etc"/>

  <!-- Directories for JUnit test cases and related files -->
  <property name="tests.dir" value="${src.dir}/testcases"/>
  <property name="tests.etc.dir" value="${src.dir}/etc/testcases"/>

  <!-- File types that should not be passed through a filterchain when
   !   copying -->
  <property name="unfiltered.files"
            value="**/*.gif,**/*.png,**/*.jpg,**/*.ico"/>

  <!-- Directories to receive the various build components -->
  <property name="build.dir" value="${basedir}/build"/>
  <property name="build.classes" value="${build.dir}/classes"/>
  <property name="build.javadocs" value="${build.dir}/javadocs"/>
  <property name="build.docs" value="${build.dir}/docs"/>
  <property name="build.etc" value="${build.dir}/etc"/>
  <property name="build.java" value="${build.dir}/java"/>
  <property name="build.tests" value="${build.dir}/testcases"/>
  <property name="build.tests.javadocs" value="${build.dir}/javadocs.test/"/>

  <!-- Distribution directories, these are created in the current
   !   directory, unless dist.dir is redefined. Files that will be
   !   installed under a package name prefixed directory should be
   !   placed in the ".pkg" variants. Note some build components may
   !   be placed directly here for efficiency-->
  <property name="dist.dir" value="${basedir}"/>
  <property name="dist.bin" value="${dist.dir}/bin"/>
  <property name="dist.lib" value="${dist.dir}/lib"/>
  <property name="dist.src" value="${dist.dir}/src"/>
  <property name="dist.docs" value="${dist.dir}/docs"/>
  <property name="dist.etc" value="${dist.dir}/etc"/>
  <property name="dist.osx" value="${dist.dir}/osx-${name}"/>
  <property name="dist.osx.bin"
            value="${dist.osx}/${Name}.app/Contents/Resources/bin"/>
  <property name="dist.dmgfile" value="${dist.dir}/${name}-full.dmg"/>

  <property name="dist.bin.pkg" value="${dist.bin}"/>
  <property name="dist.lib.pkg" value="${dist.lib}/${name}"/>
  <property name="dist.docs.pkg" value="${dist.docs}/${name}"/>
  <property name="dist.etc.pkg" value="${dist.etc}/${name}"/>
  <property name="dist.javadocs" value="${dist.docs}/${name}/javadocs"/>

  <!-- Version for zipped/tarred export files. -->
  <property name="dist.version" value="${name}-${version}"/>

  <!-- File for logging the files that are copied by the install target -->
  <property name="install.log" value=".${name}.install"/>
  <property name="install.overwrite" value="true"/>

  <!-- Local webstart properties. Note this needs a local keystore,
   !   assumed to be called keystore in $star.build.dir, .. by
   !   default. -->
  <property name="webstart.codebase" 
           value="http://starlink.jach.hawaii.edu/starjava/lib"/>
  <property name="webstart.alias" value="Starlink-UK"/>
  <property name="webstart.keystore" value="${star.build.dir}/keystore"/>
  <property name="webstart.keypass" value="Vroomfondel"/>
  <property name="webstart.storepass" value="Majikthise"/>
  <property name="webstart.starlink_logo" value="starlink_logo_med.gif"/>
  <property name="home.page" value="http://www.starlink.ac.uk/${name}/"/>

  <!-- Directory containing plot2 example graphics in the TTOOLS package. -->
  <property name="plot2.figdir"
            value="/usr/share/doc/stilts/examples"/>

  <!-- Add any local ANT tasks that are required (these should be
   !   moved to ANT if useful beyond the needs of this package) -->

  <!--
   !   =========
   !   CLASSPATH
   !   =========
   !-->

  <!-- Name all the jar files that we directly depend on. These will be
   !   used to produce a full CLASSPATH that is equivalent to that
   !   generated when these are referenced as optional bundled packages.
   !   It's best to have a classpath (rather than use the extension
   !   mechanism) during development as this allows us to compile
   !   without having to work these dependencies out anyway (may
   !   be fixed in Java1.5) plus we can execute against locally built
   !   class files in preference to installed ones (an extra user-define
   !   defined CLASSPATH can also be used as needed).
   !-->
  <path id="installed.classpath">
    <pathelement location="${star.jar.dir}/starlink-table.jar"/>
    <pathelement location="${star.jar.dir}/starlink-ttools.jar"/>
    <pathelement location="${star.jar.dir}/starlink-util.jar"/>
    <pathelement location="${star.jar.dir}/starlink-datanode.jar"/>
    <pathelement location="${star.jar.dir}/starlink-fits.jar"/>
    <pathelement location="${star.jar.dir}/starlink-task.jar"/>
    <pathelement location="${star.jar.dir}/starlink-vo.jar"/>
    <pathelement location="${star.jar.dir}/starlink-votable.jar"/>
    <pathelement location="${star.jar.dir}/jhall.jar"/>
    <pathelement location="${star.jar.dir}/jel.jar"/>
    <pathelement location="${star.jar.dir}/jsamp.jar"/>
    <pathelement location="${star.jar.dir}/fits.jar"/>
    <pathelement location="${star.jar.dir}/cds.moc.jar"/>
	   <pathelement location="/usr/lib/jvm/default-java/lib/tools.jar"/>
  </path>

  <path id="jar.classpath">
    <pathelement location="${dist.lib.pkg}/starlink-table.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-ttools.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-util.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-datanode.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-fits.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-task.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-vo.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-votable.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-topcat_demo.jar"/>
    <pathelement location="${dist.lib.pkg}/jhall.jar"/>
    <pathelement location="${dist.lib.pkg}/jel.jar"/>
    <pathelement location="${dist.lib.pkg}/jsamp.jar"/>
    <pathelement location="${dist.lib.pkg}/fits.jar"/>
    <pathelement location="${dist.lib.pkg}/cds.moc.jar"/>
  </path>

  <!-- Generate the local build classpath. This is the most difficult
   !   part of handling the classpath. The local classes will be in
   !   the "build/classes" part of each package, plus third party
   !   packages will have their jar files in the "dist" directories.
   !   Having the third party jars not installed means that building a
   !   classpath based on their manifest class-paths will not resolve
   !   all references (these may be to other third party jars, that
   !   are normally resolved using relative URLs). The way that this
   !   is resolved is simply to locate all "build/classes" directories
   !   and all jar files in the "dist" parts and just add these all
   !   to the classpath. Known third party dependencies are added
   !   after the "build/classes" directories using the "extclasspath"
   !   type, just so that they will be referred to first. If this
   !   doesn't work as expected add the additional classes/jars to
   !   the extra classpath.
   !-->
  <path id="built.jarpath"/>

  <!-- "Local" third party jars. Normally these will be kept in their
   !   own third party package, but may be kept here temporarily, say
   !   if there are version conflicts that cannot be addressed.
   !   They are installed with the package jar files and should be
   !   entered into the main jar file manifest.
   !-->
  <path id="package.jars">
     <fileset dir="${src.jars.dir}">
        <include name="*.jar"/>
     </fileset>
  </path>

  <path id="built.classpath">

    <!-- Local third party jars -->
    <path refid="package.jars"/>

    <!-- All locally built classes -->
    <dirset dir="${star.build.dir}">
      <include name="*/build/classes"/>
    </dirset>

    <!-- Directly dependent third party jars -->
    <path refid="built.jarpath"/>

    <!-- Finally add all "dist" jar files to make sure everything is
     !   resolved, including relative URLs out of the local package -->
    <fileset dir="${star.build.dir}">
      <include name="*/lib/*/*.jar"/>
    </fileset>

    <!-- Note in passing a more elegant way to resolve these jars
     !   would be to extend <extclasspath> to go looking for dependent
     !   jars using an additional URL resolving mechanism-->

  </path>

  <!-- Extra user-defined classpath. This is set by the property
   !   "extra.class.path" (which can be defined locally using say
   !   -Dextra.class.path=$CLASSPATH on the command line or by setting
   !   the property in either of the properties files.-->
  <property name="extra.class.path" value=""/>
  <path id="local.classpath" path="${extra.class.path}"/>

  <!-- Unification of all classpaths using extra, built, installed order-->
  <path id="classpath">
    <path refid="local.classpath"/>
    <path refid="built.classpath"/>
    <path refid="installed.classpath"/>
  </path>

  <!-- JUnit tests classpath, add tests.dir and tests.etc.dir so that
   !   resources may be located there -->
  <path id="tests-classpath">
    <pathelement location="${build.classes}"/>
    <pathelement location="${build.tests}"/>
    <pathelement location="${tests.dir}"/>
    <pathelement location="${tests.etc.dir}"/>
    <pathelement location="${star.jar.dir}/xdoc/xdoc.jar"/>
    <pathelement location="${build.etc}/demo"/>
    <path refid="classpath"/>
    <pathelement location="${star.jar.dir}/${name}.jar"/>
    <pathelement location="${star.jar.dir}/junit.jar"/>
  </path>

  <!-- Need installed JNIAST for javadoc fun and games - this seems to do it
   !   (though maybe means the main classpath is broken??) -->
  <path id="docs-classpath">
    <path refid="installed.classpath"/>
    <path refid="classpath"/>
  </path>

  <!-- Turn this path into a string which is passed to the tests -->
  <property name="tests-classpath.value" refid="tests-classpath"/>

  <!--
   !    ============
   !    Library path
   !    ============
   !    Used by test targets for locating native libraries.
   !-->
  <path id="tests-libpath.id">
    <pathelement path="${java.library.path}"/>
    <pathelement location="${star.jar.dir}/${os.arch}"/>
  </path>
  <property name="tests-libpath" refid="tests-libpath.id"/>

  <!--
   !    =========================================
   !    Check availability of direct dependencies
   !    =========================================
   !    (could also use this to check optional elements).
   !
   ! If any of the required dependencies are not present then
   ! this throws a <fail> and exits the build.
   !-->
  <target name="check_packages"
          unless="runonly.install">

    <!-- UTIL -->
    <available property="util.present"
               classpathref="classpath"
               classname="uk.ac.starlink.util.DataSource"/>
    <fail message="No UTIL available" unless="util.present"/>

    <!-- TABLE -->
    <available property="table.present"
               classpathref="classpath"
               classname="uk.ac.starlink.table.StarTable"/>
    <fail message="No TABLE available" unless="table.present"/>

    <!-- HELP -->
    <available property="help.present"
               classpathref="classpath"
               classname="javax.help.JHelp"/>
    <fail message="No HELP available" unless="help.present"/>

    <!-- Need JUnit for testcases, not essential -->
    <available property="junit.present"
               classpathref="classpath"
               classname="junit.framework.TestCase"/>

  </target>

  <!--
   !   =================
   !   Prepare the build
   !   =================
   !
   !  Do any jobs that are required before any other target can proceed.
   !-->
  <target name="prepare">

    <tstamp>
      <format property="year" pattern="yyyy"/>
    </tstamp>

    <!-- Human-readable copyright string -->
    <property name="copyright.string"
              value="Copyright &#169; 2003-${year} CCLRC: Council for the Central Laboratory of the Research Councils.  All Rights Reserved."/>

    <!-- This is a filterchain that can be used to copy-edit files
     !   that require the package version, current date and/or time -->
    <filterchain id="filters">
      <replacetokens>
        <token key="VERSION" value="${version}"/>
        <token key="DATE" value="${TODAY}"/>
        <token key="TIME" value="${TSTAMP}"/>
      </replacetokens>
    </filterchain>

  </target>


  <!--
   !   ==============
   !   Build the code
   !   ==============
   !
   !  The results of the compilation are placed in the build.classes
   !  directory. Other files that are also needed in the classes tree
   !  (i.e. resources like images and property files) should also be
   !  copied into place here. 
   !-->
  <target name="build"
          depends="prepare, check_packages"
          unless="runonly.install"
          description="-> compiles the source code">

    <mkdir dir="${build.classes}"/>
    <javac srcdir="${java.dir}"
           destdir="${build.classes}"
           debug="${debug}"
           deprecation="${deprecation}"
           encoding="cp1252"
           includeantruntime="false"
           optimize="${optimize}">

      <classpath refid="classpath"/>

      <!-- Exclude any files in the source tree that should not be
       !   compiled -->
      <exclude name="**/{Retired1.java}"/>
      <exclude name="**/{Retired2.java}"/>
      <exclude name="**/*.html"/>
      <exclude name="**/*.properties*"/>

      <exclude name="uk/ac/starlink/topcat/interop/TopcatPlasticListener.java"/>
      <exclude name="uk/ac/starlink/topcat/interop/PlasticCommunicator.java"/>
      <exclude name="uk/ac/starlink/topcat/interop/SelectivePlasticListModel.java"/>
      <exclude name="uk/ac/starlink/topcat/interop/TopcatTransmitter.java"/>
      <exclude name="uk/ac/starlink/topcat/interop/PlasticImageActivity.java"/>
      <exclude name="uk/ac/starlink/topcat/func/Sog.java"/>
      <exclude name="uk/ac/starlink/topcat/activate/ViewImageActivationType.java"/>
      <exclude name="uk/ac/starlink/topcat/activate/RegionViewImageActivationType.java"/>
      <exclude name="uk/ac/starlink/topcat/activate/GenericViewImageActivationType.java"/>
   </javac>

    <!-- Copy extra files that should live with packages classes
     !   (i.e. are discovered using "getResource()"). -->
    <copy todir="${build.classes}">
      <fileset dir="${src.dir}/resources"/>
    </copy>
    <copy todir="${build.classes}/uk/ac/starlink/topcat">
      <fileset dir="${src.docs}" includes="figures/*"/>
    </copy>
    <copy todir="${build.classes}/uk/ac/starlink/topcat/figures">
      <fileset dir="${plot2.figdir}"
               includesfile="${plot2.figdir}/plot2-figs.lis"/>
    </copy>

    <!-- Write some required PNGs to the images directory programatically. -->
    <java classname="uk.ac.starlink.topcat.ResourceIcon"
          failonerror="yes"
          dir="${build.classes}/uk/ac/starlink/topcat/images/"
          fork="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <classpath refid="classpath"/>
      <arg value="-writepngs"/>
    </java>

    <!-- Version string. -->
    <echo file="${build.classes}/uk/ac/starlink/topcat/version-string"
          message="${version}-debian"/>

    <!-- Local third party jars, if any. Copy straight into
     !   distribution directories to save on unnecessary copies and to
     !   make these available for resolution by other locally built
     !   packages that are using this one -->
    <mkdir dir="${dist.lib.pkg}"/>
    <copy todir="${dist.lib.pkg}">
       <fileset dir="${src.jars.dir}"/>
    </copy>

    <!-- Call target to do time-consuming build of additional components;
     !   first check that they are not already in place. -->
    <condition property="extras.built">
      <and>
        <uptodate targetfile="${build.javadocs}/uk/ac/starlink/topcat/func">
          <srcfiles dir="${java.dir}/uk/ac/starlink/topcat/func/"/>
        </uptodate>
        <uptodate targetfile="${build.etc}/demo">
          <srcfiles dir="${src.etc}/demo"/>
        </uptodate>
      </and>
    </condition>
    <antcall target="build-extras"/>

  </target>

  <!-- Sub-target to perform time-consuming build of additional components
   !   in build phase; unless attribute allows it to be skipped. -->
  <target name="build-extras" unless="extras.built">

    <!-- Construct HTML documentation for the JEL-accessible classes.
     !   This is built using Javadoc, and is available from the MethodWindow
     !   method browser. -->
    <javadoc doclet="uk.ac.starlink.ttools.build.HtmlDoclet"
             docletpathref="classpath"
             failonerror="true"
             public="true"
             destdir="${build.javadocs}"
             classpathref="classpath"
             encoding="cp1252">
      <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
        <include name="*.java"/>
        <exclude name="Sog.java"/>
      </fileset>
    </javadoc>

     <antcall target="build_demo"/>
  </target>

  <!--
   !   ==========================
   !   Build standalone jar files
   !   ==========================
   !
   !  Builds jar files which can be used on their own, without needing any
   !  other jars to be present.  Two of them are built: topcat-lite.jar
   !  which contains enough classes to do most things but not support for
   !  peripheral items like MySpace access etc.
   !-->
  <target name="build-standalone"
          depends="install"
          description="-> builds a standalone jar file">

    <!-- Build temporary zip file containing things not in the input jars
     !   which ought to be included in the standalone jars. -->
    <exec outputproperty="gitversion"
          logerror="true"
          executable="${star.dir}/bin/gitversion"/>
    <echo message="${gitversion}"
          file="${build.classes}/uk/ac/starlink/topcat/revision-string"/>
    <mkdir dir="${build.classes}/uk/ac/starlink/ttools"/>
    <echo message="${gitversion}"
          file="${build.classes}/uk/ac/starlink/ttools/revision-string"/>

    <zip destfile="${dist.lib.pkg}/extras.zip">
      <fileset dir="${star.bin}" includes="topcat stilts"/>
      <fileset dir="${star.dir}/source/src/etc" includes="LICENCE.txt"/>
      <fileset dir="${star.etc}/ttools" includes="stilts.py"/>
      <fileset dir="${build.classes}">
        <include name="uk/ac/starlink/topcat/revision-string"/>
        <include name="uk/ac/starlink/ttools/revision-string"/>
      </fileset>
    </zip>
    <delete file="${build.classes}/uk/ac/starlink/topcat/revision-string"/>
    <delete file="${build.classes}/uk/ac/starlink/ttools/revision-string"/>

    <!-- Build topcat-lite.jar - minimal standalone which does basic things. -->
    <java classname="uk.ac.starlink.util.SuperJar" failonerror="yes">
      <classpath refid="classpath"/>
      <arg value="-oj"/><arg value="${dist.lib.pkg}/topcat-lite.jar"/>
      <arg value="-xjar"/><arg value="array.jar"/>
      <arg value="-xjar"/><arg value="astrogrid.jar"/>
      <arg value="-xjar"/><arg value="axis.jar"/>
      <arg value="-xjar"/><arg value="hds.jar"/>
      <arg value="-xjar"/><arg value="hdx.jar"/>
      <arg value="-xjar"/><arg value="jaiutil.jar"/>
      <arg value="-xjar"/><arg value="jniast.jar"/>
      <arg value="-xjar"/><arg value="junit.jar"/>
      <arg value="-xjar"/><arg value="ndx.jar"/>
      <arg value="-xjar"/><arg value="sog.jar"/>
      <arg value="-xjar"/><arg value="soapserver.jar"/>
      <arg value="-xjar"/><arg value="srb.jar"/>
      <arg value="-xent"/><arg value="COPYING.txt"/>
      <arg value="-xent"/><arg value="README.txt"/>
      <arg value="-xent"/><arg value="package cache/"/>
      <arg value="${star.lib.pkg}/topcat.jar"/>
      <arg value="${dist.lib.pkg}/extras.zip"/>
    </java>

    <java classname="uk.ac.starlink.util.SuperJar" failonerror="yes">
      <classpath refid="classpath"/>
      <arg value="-oj"/><arg value="${dist.lib.pkg}/topcat-full.jar"/>
      <arg value="-xjar"/><arg value="junit.jar"/>
      <arg value="-xjar"/><arg value="log4j.jar"/>
      <arg value="-xjar"/><arg value="log4j-core.jar"/>
      <arg value="-xjar"/><arg value="jsky/jel.jar"/>
      <arg value="-xjar"/><arg value="gsi-classes.jar"/>
      <arg value="-xent"/><arg value="COPYING.txt"/>
      <arg value="-xent"/><arg value="README.txt"/>
      <arg value="-xent"/><arg value="package cache/"/>
      <arg value="${star.lib.pkg}/topcat.jar"/>
      <arg value="${dist.lib.pkg}/extras.zip"/>
    </java>

    <delete file="${dist.lib.pkg}/extras.zip"/>

    <echo message="standalone jar files not signed"/>
    <!--
     !   <signjar alias="${webstart.alias}"
     !            keystore="${webstart.keystore}"
     !            keypass="${webstart.keypass}"
     !            storepass="${webstart.storepass}">
     !     <fileset dir="${dist.lib.pkg}"
     !              includes="topcat-lite.jar topcat-full.jar"/>
     !   </signjar>
     !-->
  </target>

  <!--
   !   ===================
   !   Construct demo data
   !   ===================
   !-->
  <target name="build_demo">
    <property name="src.demo" value="${src.etc}/demo"/>
    <property name="build.demo" 
              value="${build.etc}/demo/uk/ac/starlink/topcat/demo"/>
    <mkdir dir="${build.demo}"/>

    <!-- Set up a file recording which demo files are to be used. -->
    <property name="demo.list" value="${build.demo}/demo_list"/>
    <delete file="${demo.list}" quiet="true"/>
    <touch file="${demo.list}"/>

    <bzip2 src="${src.demo}/votable/6dfgs_mini.xml"
           destfile="${build.demo}/6dfgs_mini.xml.bz2"/>
    <echo append="true" file="${demo.list}" message="6dfgs_mini.xml.bz2&#xA;"/>

    <copy todir="${build.demo}">
      <fileset dir="${src.demo}/fits" includes="863sub.fits"/>
      <fileset dir="${src.demo}/votable" includes="messier.xml,vizier.xml.gz"/>
    </copy>
    <echo append="true" file="${demo.list}" message="messier.xml&#xA;"/>
    <echo append="true" file="${demo.list}" message="vizier.xml.gz&#xA;"/>
    <echo append="true" file="${demo.list}" message="863sub.fits&#xA;"/>

    <gzip src="${src.demo}/fits/tables.fit"
          zipfile="${build.demo}/tables.fit.gz"/>
    <echo append="true" file="${demo.list}" message="tables.fit.gz&#xA;"/>

    <tar destfile="${build.demo}/demo.tar.bz2"
         compression="bzip2">
      <tarfileset dir="${src.etc}">
        <include name="demo/votable/messier.xml"/>
        <include name="demo/fits/tables.fit"/>
        <include name="demo/others/**"/>
      </tarfileset>
    </tar>
    <echo append="true" file="${demo.list}" message="demo.tar.bz2&#xA;"/>
  </target>


  <!--
   !   ============================
   !   Create the package jar files
   !   ============================
   !
   !  Creates a jar file from the build.classes directory tree. If
   !  jars of sub-components are also required these should be also
   !  created here. Note this requires a manifest file that defines the
   !  jars that we directly depend on (using relative URLs) on and
   !  defines the application entrance point. The jar files should be
   !  placed directly in the distribution directories. 
   !-->
  <target name="jars"
          depends="build, docs-html"
          unless="runonly.install"
          description="-> creates the package jar file(s)">

    <mkdir dir="${dist.lib.pkg}"/>
    <manifestclasspath property="jar.class.path"
                       jarfile="${dist.lib.pkg}/${name}.jar">
      <classpath refid="jar.classpath" />
    </manifestclasspath>
    <jar destfile="${dist.lib.pkg}/${name}.jar">
      <fileset dir="${build.classes}"/>
      <fileset dir="${build.javadocs}"/>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
        <attribute name="Main-Class"
                   value="uk.ac.starlink.topcat.Driver"/>
        <attribute name="Class-Path" value="${jar.class.path}"/>
        <!-- Required for WebStart signed jars at java 7u51+ -->
        <attribute name="Permissions" value="all-permissions"/>
        <attribute name="Application-Name" value="TOPCAT"/>
      </manifest>
    </jar>

    <jar destfile="${dist.lib.pkg}/${name}_demo.jar"
         basedir="${build.etc}/demo"/>

  </target>

  <!--
   !   ========================================
   !   Make package JNLP file for Java webstart
   !   ========================================
   !-->
  <target name="webstart"
          description="-> create webstart descriptor files">

    <!-- Create a webstart JNLP file for this package, this goes into
     !   "dist.lib" -->
    <mkdir dir="${dist.lib}"/>
    <jnlp toFile="${dist.lib}/${name}.jnlp" href="${name}.jnlp"
          codebase="${webstart.codebase}">
      <information>
         <title>TOPCAT</title>
         <vendor>Mark Taylor, Bristol University</vendor>
         <homepage href="${home.page}"/>
         <icon href="${home.page}images/tc_sok.png"/>
         <description>"TOPCAT - Tool for OPerations on Catalogues And Tables"</description>
         <offline_allowed/>
       </information>
       <security>
          <all_permissions/>
       </security>
       <resources>
         <j2se version="1.5+"/>
         <jar href="${name}/${name}.jar"/>
         <extension name="TOPCAT-PARTS" href="${name}-parts.jnlp"/>
       </resources>
       <application_desc main_class="uk.ac.starlink.topcat.Driver"/>
     </jnlp>

     <!-- May be needed as a component so provide that too -->
     <jnlp toFile="${dist.lib}/${name}-parts.jnlp" href="${name}-parts.jnlp"
          codebase="${webstart.codebase}">
      <information>
         <title>TOPCAT - Tool for OPerations on Catalogues And Tables</title>
         <vendor>Starlink UK</vendor>
         <homepage href="${home.page}"/>
         <icon href="${webstart.starlink_logo}"/>
         <description>"Starlink TOPCAT - Webstart edition"</description>
         <offline_allowed/>
       </information>
       <security>
          <all_permissions/>
       </security>
       <resources>
         <j2se version="1.5+"/>
         <fileset dir="${dist.lib}" includes="**/*.jar **/*.zip"/>
         <extension name="TTOOLS" href="ttools.jnlp"/>
         <extension name="DATANODE" href="datanode.jnlp"/>
         <extension name="HELP" href="help.jnlp"/>
         <extension name="CONNECT" href="connect.jnlp"/>
         <extension name="ASTROGRID" href="astrogrid.jnlp"/>
         <extension name="SRB" href="srb.jnlp"/>
         <extension name="PLASTIC" href="plastic.jnlp"/>
       </resources>
       <component_desc/>
     </jnlp>

  </target>

  <!-- Create an MacOS X Java application bundle, using the osxjarbundler ant
   !   task built (see http://jarbundler.sourceforge.net).
   !   Additionally, create a .dmg file for distribution.
   !-->
  <target name="build-osxapp"
          depends="build_demo,build-standalone"
          description="-> builds .dmg application bundle for MacOS X">
    <delete dir="${dist.osx}" quiet="true"/>
    <mkdir dir="${dist.osx}"/>
    <!-- 'Infostring' should not contain a version number (as of OS X
     !   10.4 - see docs for CFBundleGetInfoString); 'version' should
     !   be the `marketing version of the bundle' (ie, the release
     !   version); 'buildnumber' can optionally hold a rolling build number.
     !   -->
    <!-- The JVMVersion is set to 1.8+; the default is 1.3+.
     !   1.8 is preferred since there are some (minor) problems with
     !   Apple (1.6) Java on OSX, apparently solved with the
     !   1.8 (Oracle/OpenJDK) series.
     !   It's not clear if the OSX runtime honours this setting though.
     !-->
    <osxjarbundler dir="${dist.osx}"
                mainclass="${package.name}.Driver"
                name="${Name}"
                shortname="${Name}"
                aboutmenuname="${Name}"
                bundleid="${package.name}"
                stubfile="${src.dir}/lib/MacOS/TopcatUJAStub"
                icon="${src.dir}/lib/MacOS/Topcat.icns"
                infostring="${Name} ${copyright.string}"
                vmoptions=""
                version="${version}"
                jvmversion="1.8+"
                workingdirectory="$USER_HOME"
                jar="${dist.lib.pkg}/topcat-full.jar">

      <!-- demo data lives in ${src.etc}/demo (see target build_demo) -->
      <resourcefileset dir="${src.etc}"
                       includes="demo/**"/>
      <javaproperty name="uk.ac.starlink.topcat.demodir"
                    value="$APP_PACKAGE/Contents/Resources/demo"/>

      <javaproperty name="uk.ac.starlink.topcat.cmdname"
                    value="topcat"/>
      <!-- Put the menus in the screen menu bar, rather than an
           application-specific one -->
      <javaproperty name="apple.laf.useScreenMenuBar" value="true"/>

    </osxjarbundler>

    <!-- Hack the Java section of the Info.plist file so that the section
     !   key is headed JavaUJAS instead of Java.  This key is then used
     !   by the (also hacked) TopcatUJAStub stub file to interrogate the plist.
     !   This appears to be necessary to prevent OSX from doing something
     !   magic with the Java section.
     !   See https://github.com/tofi86/universalJavaApplicationStub/issues/9 -->
    <replace file="${dist.osx}/${Name}.app/Contents/Info.plist"
             token="&lt;key&gt;Java&lt;/key&gt;"
             value="&lt;key&gt;JavaUJAS&lt;/key&gt;"/>

    <!-- Copy the docs into the release directory -->
    <mkdir dir="${dist.osx}/docs"/>
    <copy todir="${dist.osx}/docs">
      <fileset dir="${dist.docs}/${name}" excludes="javadocs javadocs/**"/>
    </copy>

    <!-- Copy scripts into the release directory.  These used to just go
     !   in /bin at the top.  However, the Homebrew people want it to
     !   go inside TOPCAT.app, so it can get symlinked from ... somewhere.
     !   So I've put them in /TOPCAT.app/Contents/Resources/bin as well
     !   (I took advice on what the best place was and got various
     !   different answers, but this seems fairly unobjectionable).
     !   Possibly I should remove them from /bin now, but they've been
     !   there a long time, so leave them be lest changing it breaks
     !   some people's usage. -->
    <mkdir dir="${dist.osx}/bin"/>
    <copy todir="${dist.osx}/bin">
      <fileset dir="${star.bin}" includes="topcat stilts"/>
    </copy>
    <mkdir dir="${dist.osx.bin}"/>
    <copy todir="${dist.osx.bin}">
      <fileset dir="${star.bin}" includes="topcat stilts"/>
    </copy>
    <chmod perm="ugo+x" type="file" failonerror="yes" maxparallel="50">
      <fileset dir="${dist.osx}/bin"/>
      <fileset dir="${dist.osx.bin}"/>
    </chmod>

    <mkdir dir="${dist.osx}/README.rtfd"/>
    <copy todir="${dist.osx}/README.rtfd">
      <fileset dir="${src.dir}/lib/MacOS/README.rtfd"/>
    </copy>

    <!-- The final step - generating the .dmg file - can only be done on
     !   a Mac.  Either do it, or write a message saying how.  If the build
     !   is being done on a non-Mac system, just copy the ${dist.osx} 
     !   directory to a Mac and run hdiutil there. -->
    <condition property="isMacos">
      <os family="mac"/>
    </condition>
    <!-- Note: to examine the dmg file on OSX do 
     !      % hdiutil attach topcat.dmg 
     ! ...  % hdiutil detach /dev/... -->
    <echo message="Attempt to build .dmg file (will only work on Mac)"/>
    <echo message="   hdiutil create -srcfolder ${dist.osx} -volname ${name} -ov ${dist.dmgfile}"/>
    <exec executable="/usr/bin/hdiutil" os="Mac OS X">
      <arg value="create"/>
      <arg value="-srcfolder"/>
      <arg value="${dist.osx}"/>
      <arg value="-volname"/>
      <arg value="${name}"/>
      <arg value="-ov"/>
      <arg value="${dist.dmgfile}"/>
    </exec>
  </target>

  <!--
   !   =================================
   !   Configures the local distribution
   !   =================================
   !
   !  Completes the creation of the local distribution into the
   !  directory "dist.dir" (usually the current directory).
   !  Installations and exports are based on the state of this
   !  distribution, so it must be performed before installation or
   !  export. If the "runonly.install" parameter is set then this
   !  target is skipped (needed for releases that do not have
   !  source). Much of the work of getting the distribution
   !  directories into the correct state is performed by the dependency
   !  targets.
   !-->
  <target name="dist"
          depends="build,docs-html,jars,javadocs,webstart"
          unless="runonly.install"
          description="-> configures the local binary distribution">

    <!-- Make sure all the distribution directories exist -->
    <mkdir dir="${dist.dir}"/>
    <mkdir dir="${dist.bin.pkg}"/>
    <mkdir dir="${dist.lib.pkg}"/>
    <mkdir dir="${dist.docs.pkg}"/>
    <mkdir dir="${dist.etc.pkg}"/>

    <!-- Copy application scripts. -->
    <copy todir="${dist.bin.pkg}">
      <fileset dir="${script.dir}/" />
    </copy>

    <!-- Copy extra documentation, note doesn't include javadocs these
     !   are generated from the source-->
    <copy todir="${dist.docs.pkg}">
      <fileset dir="${build.docs}"
               includes="images/* figures/* ${user.doc}/* *.pdf"/>
    </copy>

    <!-- Set permissions on contents of distribution directories -->
    <chmod perm="ugo+rx" dir="${dist.dir}" type="dir" includes="**"
           failonerror="${chmod.fail}" maxparallel="50"/>
    <chmod perm="ugo+r" dir="${dist.dir}" type="file" includes="**"
           failonerror="${chmod.fail}" maxparallel="50"/>
    <chmod perm="ugo+x" type="file" failonerror="${chmod.fail}"
           maxparallel="50">
       <fileset dir="${dist.bin}"/>
    </chmod>

  </target>

  <!--
   !   ========================
   !   Create the full releases
   !   ========================
   !
   !  Creates the full "zip", "tar" and "bzip" archives of the
   !  products of the "dist" target and the source directory.
   !  The archives are designed to be unpacked such that the resultant
   !  directory layout can be either used as a local distribution, or
   !  installed into a Starlink tree (installation requires the
   !  Starlink modified version of ANT, use as a local distribution
   !  may need special handling of the extension path). This version
   !  can also be used to rebuild the package from source.
   !
   !  The archive names are ${dist.version}.<ext>.
   !-->
  <target name="export"
          description="-> creates the full distribution archives">

    <antcall target="create_archives">
      <param name="source.required" value="true"/>
      <param name="binary.required" value="true"/>
      <param name="archive.name" value="${dist.version}"/>
    </antcall>

  </target>

  <!--
   !   ==========================
   !   Create the source releases
   !   ==========================
   !
   !  Creates the source only "zip", "tar" and "bzip" archives.
   !  These can be used to rebuild the package (requires the Starlink
   !  modified version of ANT).
   !
   !  The archive names are ${dist.version}-src.<ext>.
   !-->
  <target name="export-source"
          description="-> creates the source distribution archives">

     <antcall target="create_archives">
      <param name="source.required" value="true"/>
      <param name="archive.name" value="${dist.version}-src"/>
    </antcall>

  </target>

  <!--
   !   ===========================
   !   Create the runonly releases
   !   ===========================
   !
   !  Creates the runonly "zip", "tar" and "bzip" archives of the
   !  products of the "dist" target. The archives are designed to be
   !  unpacked such that the resultant directory layout can be either
   !  used as a local distribution, or installed into a Starlink tree
   !  (installation requires the Starlink modified version of ANT).
   !
   !  The archive names are ${dist.version}-bin.<ext>.
   !-->
  <target name="export-runonly"
          description="-> creates the runonly distribution archives">

     <antcall target="create_archives">
      <param name="binary.required" value="true"/>
      <param name="archive.name" value="${dist.version}-bin"/>
    </antcall>

  </target>

  <!--
   ! Create release archives of the various types required. Use this
   ! by an <antcall> and set the property "archive.name" to define what
   ! name to use for the outfile files. The archives are written into
   ! the directory ${star.archive.dir} (the local directory by default).
   !
   ! If the property "binary.required" is set then the files needed
   ! for a run-only release are included and if "source.required" is
   ! defined the source code is also included.
   !-->
  <target name="create_archives"
          depends="dist">

    <mkdir dir="${star.archive.dir}"/>

    <zip destfile="${star.archive.dir}/${archive.name}.zip">

      <!-- All releases have the documentation and build file -->
      <zipfileset dir="${dist.docs}" prefix="${name}/docs"/>
      <zipfileset dir="${dist.dir}" includes="build.xml" prefix="${name}"/>

      <zipfileset dir="${dist.bin}" prefix="${name}/bin">
        <include name="**" if="binary.required"/>
      </zipfileset>
      <zipfileset dir="${dist.lib}" prefix="${name}/lib">
        <include name="**" if="binary.required"/>
      </zipfileset>
      <zipfileset dir="${dist.etc}" prefix="${name}/etc">
        <include name="**" if="binary.required"/>
      </zipfileset>

      <zipfileset dir="${src.dir}" prefix="${name}/src">
        <include name="**" if="source.required"/>

        <!-- Exclude local development support from distribution-->
        <exclude name="local/**" if="source.required"/>
      </zipfileset>

    </zip>

    <!-- Note: creating a tar file with empty directories doesn't
     !   work, so the directory structure may be incomplete -->
    <tar longfile="gnu" destfile="${archive.name}.tar">

      <!-- All releases have the documentation and build file -->
      <tarfileset dir="${dist.docs}" prefix="${name}/docs"/>
      <tarfileset dir="${dist.dir}" prefix="${name}">
        <include name="build.xml"/>
      </tarfileset>

      <tarfileset dir="${dist.bin}" prefix="${name}/bin">
        <include name="**" if="binary.required"/>
      </tarfileset>
      <tarfileset dir="${dist.lib}" prefix="${name}/lib">
        <include name="**" if="binary.required"/>
      </tarfileset>
      <tarfileset dir="${dist.etc}" prefix="${name}/etc">
        <include name="**" if="binary.required"/>
      </tarfileset>

      <tarfileset dir="${src.dir}" prefix="${name}/src">
        <include name="**" if="source.required"/>
        <exclude name="local/**" if="source.required"/>
      </tarfileset>

    </tar>

    <gzip zipfile="${star.archive.dir}/${archive.name}.tar.gz"
          src="${archive.name}.tar"/>
    <bzip2 zipfile="${star.archive.dir}/${archive.name}.tar.bz2"
           src="${archive.name}.tar"/>
    <delete file="${archive.name}.tar"/>

  </target>

  <!--
   !   ============================================
   !   Cleans up build and distribution directories
   !   ============================================
   !-->
  <target name="clean"
          description="-> cleans up build and dist products">

    <delete dir="${build.dir}"/>
    <delete dir="${dist.bin}"/>
    <delete dir="${dist.lib}"/>
    <delete dir="${dist.docs}"/>
    <delete dir="${dist.etc}"/>
    <delete dir="${dist.osx}" quiet="true"/>
    <delete dir="${dist.dmgfile}" quiet="true"/>
  </target>

  <!--
   !   ================================
   !   Install into the "Starlink" tree
   !   ================================
   !
   ! Installs the "dist" target products into another set of
   ! directories.
   !
   ! An installed system is potentially "undoable" as the copied names
   ! and package-specific directories are logged to "${install.log}".
   !-->
  <target name="install"
          depends="dist"
          description="-> installs distribution">

    <!-- Installation based directories (based on "star.install")-->
    <property name="star.bin" value="${star.install}/bin"/>
    <property name="star.lib" value="${star.install}/lib"/>
    <property name="star.etc" value="${star.install}/etc"/>
    <property name="star.docs" value="${star.install}/docs"/>
    <property name="star.bin.pkg" value="${star.bin}/${name}"/>
    <property name="star.lib.pkg" value="${star.lib}/${name}"/>
    <property name="star.etc.pkg" value="${star.etc}/${name}"/>
    <property name="star.docs.pkg" value="${star.docs}/${name}"/>
    <mkdir dir="${star.install}"/>
    <mkdir dir="${star.lib.pkg}"/>
    <mkdir dir="${star.docs.pkg}"/>

    <loggedcopy todir="${star.bin}"
                logfile="${install.log}"
                overwrite="${install.overwrite}"
                logfileAppend="false">
      <fileset dir="${dist.bin}"/>
    </loggedcopy>

    <!-- Also remove the package-specific directory.
     !   Note exact format is required.-->
    <echo file="${install.log}" append="true">${star.bin.pkg}
</echo>

    <chmod perm="ugo+rx" failonerror="${chmod.fail}">
      <fileset dir="${star.bin}">
        <present targetdir="${dist.bin}" present="both"/>
      </fileset>
    </chmod>

    <loggedcopy todir="${star.lib}"
                logfile="${install.log}"
                overwrite="${install.overwrite}"
                logfileAppend="true">
      <fileset dir="${dist.lib}">
        <include name="**/*.jnlp"/>
        <include name="**/*.jar"/>
        <include name="**/*.zip"/>
        <include name="**/*.icns"/>
      </fileset>
    </loggedcopy>
    <echo file="${install.log}" append="true">${star.lib.pkg}
</echo>

    <loggedcopy todir="${star.docs}"
                logfile="${install.log}"
                overwrite="${install.overwrite}"
                logfileAppend="true">
      <fileset dir="${dist.docs}" excludes="${unfiltered.files}"/>
      <filterchain refid="filters"/>
    </loggedcopy>

    <loggedcopy todir="${star.docs}" filtering="false"
                logfile="${install.log}"
                overwrite="${install.overwrite}"
                logfileAppend="true">
      <fileset dir="${dist.docs}" includes="${unfiltered.files}"/>
    </loggedcopy>
    <echo file="${install.log}" append="true">${star.docs.pkg}
</echo>

  </target>

  <!--
   !   ========================================
   !   Install runonly into the "Starlink" tree
   !   ========================================
   !
   ! Do an install using only the contents of a binary release (a
   ! source-free runonly system).
   !-->
  <target name="install-runonly"
          description="-> install a runonly distribution into Starlink tree">

     <!-- Make sure that the expected file structure exists, some
          of these files can be missing if originally empty -->
     <mkdir dir="${dist.dir}"/>
     <mkdir dir="${dist.lib.pkg}"/>
     <mkdir dir="${dist.docs.pkg}"/>

     <!-- Do normal install, but with many targets switched off-->
     <antcall target="install">
      <param name="runonly.install" value="true"/>
      <param name="javadoc.notrequired" value="true"/>
    </antcall>

  </target>

  <!--
   !   ===================================
   !   De-install from the "Starlink" tree
   !   ===================================
   !
   ! Uses the content of the "${install.log}" to remove the files
   !  that were copied into place by the install target. If this fails
   !  then hopefully the log file will not be deleted!
   !-->
 <target name="deinstall"
          description="-> undo the install target">

    <available file="${install.log}" property="install.log.present"/>

    <antcall target="real_deinstall"/>

  </target>

  <!-- Real deinstall target. Only activated if "install.log.present"
   !   is defined -->
  <target name="real_deinstall"
          if="install.log.present">

    <loadfile property="files" srcFile="${install.log}"/>
    <listdelete>
      <filelist dir="/" files="${files}"/>
    </listdelete>

    <delete file="${install.log}"/>

  </target>

  <!--
   !   =============================
   !   Creates the API documentation
   !   =============================
   !
   !  Create documentation from the Java sources. Additional
   !  documentation is kept in the ${src.docs} directory.
   !-->
  <target name="javadocs"
          depends="prepare,javadoc_check"
          unless="javadoc.notrequired"
          description="-> creates the API documentation">

    <mkdir dir="${dist.javadocs}"/>
    <javadoc useexternalfile="yes"
             destdir="${dist.javadocs}"
             author="true"
             version="true"
             locale="en"
             windowtitle="${Name} API"
             doctitle="${Name}"
             defaultexcludes="yes"
             encoding="cp1252"
             classpathref="classpath">

      <!-- Get a list of directories that name all the potential
       !   java packages -->
      <fileset dir="${java.dir}" defaultexcludes="yes">
         <include name="**/*.java"/>
         <exclude name="uk/ac/starlink/topcat/doc"/>
	 <exclude name="uk/ac/starlink/topcat/interop/TopcatPlasticListener.java"/>
	 <exclude name="uk/ac/starlink/topcat/interop/PlasticCommunicator.java"/>
	 <exclude name="uk/ac/starlink/topcat/interop/SelectivePlasticListModel.java"/>
	 <exclude name="uk/ac/starlink/topcat/interop/TopcatTransmitter.java"/>
	 <exclude name="uk/ac/starlink/topcat/interop/PlasticImageActivity.java"/>
	 <exclude name="uk/ac/starlink/topcat/func/Sog.java"/>
      </fileset>

      <!-- Link to the full Java API at SUNs website -->
      <link offline="true" href="${javaapi.url}"
            packagelistLoc="${javaapi.lis}"/>

      <!-- Cope with custom tags. -->
      <tag name="example"
           description="Examples:"
           scope="methods, fields"
           enabled="true"/>

      <group title="${Name} API" packages="${package.name}*"/>

      <bottom>${copyright.string}</bottom>
    </javadoc>

  </target>

  <!-- This checks if the javadocs are up to date with respect to the
   !   java source, if so then the "javadoc.notrequired" variable is
   !   set true. Note this is check is not performed if
   !   javadoc.notrequired is already set (by .properties) -->
  <target name="javadoc_check"
          unless="javadoc.notrequired">

    <uptodate property="javadoc.notrequired"
              targetfile="${dist.javadocs}/packages.html">
        <srcfiles dir= "${java.dir}" includes="**/*.java"/>
    </uptodate>

  </target>

  <!--
   !   ======================================================
   !   Creates additional HTML documentation from XML sources
   !   ======================================================
   !
   !   The XML user document is downconverted to single- and multiple-
   !   file HTML versions in the docs directory, and a JavaHelp version
   !   on the classpath of the application.
   !-->
  <target name="docs-html"
          depends="build, html_check, docs_depend"
          unless="docs.notrequired"
          description="-> creates the user documentation">

    <!-- Transform the user document XML to a single HTML document. -->
    <mkdir dir="${build.docs}/${user.doc}"/>
    <copy todir="${build.docs}/${user.doc}">
      <fileset dir="${xdoc.etc}" includes="sun-style.css"/>
    </copy>
    <xslt in="${build.docs}/${user.doc}.xml" 
          out="${build.docs}/${user.doc}/${user.doc}.html"
          style="${xdoc.etc}/toHTML1.xslt">
      <param name="VERSION" expression="${version}-debian"/>
      <param name="BASEDIR" expression="${build.docs}/${user.doc}"/>
      <param name="COVERIMAGE" expression="../figures/multishot-mini.png"/>
      <param name="CSS_HREF" expression="sun-style.css"/>
    </xslt>

    <!-- Transform the user document from XML to HTML form for browsing. -->
    <xslt in="${build.docs}/${user.doc}.xml"
          out="${build.docs}/${user.doc}/${user.doc}.2.html"
	  classpath="/usr/share/java/Saxon-HE.jar"
          style="${xdoc.etc}/toHTML.xslt">
      <param name="VERSION" expression="${version}-debian"/>
      <param name="BASEDIR" expression="${build.docs}/${user.doc}"/>
      <param name="COVERIMAGE" expression="../figures/multishot-mini.png"/>
      <param name="CSS_HREF" expression="sun-style.css"/>
    </xslt>

    <!-- Copy same into the classes directory so that it ends up in the
     !   jar file.  -->
    <copy todir="${build.classes}/uk/ac/starlink/topcat/${user.doc}">
      <fileset dir="${build.docs}/${user.doc}"/>
    </copy>

    <!-- Transform the user document from XML to JavaHelp form. -->
    <mkdir dir="${build.classes}/uk/ac/starlink/topcat/help"/>
    <xslt in="${build.docs}/${user.doc}.xml"
          out="${build.classes}/uk/ac/starlink/topcat/help/index.html"
	  classpath="/usr/share/java/Saxon-HE.jar"
          style="${xdoc.etc}/toHelp.xslt">
      <param name="VERSION" expression="${version}"/>
      <param name="BASEDIR" expression="${build.docs}/${user.doc}"/>
      <param name="COVERIMAGE" expression="../figures/multishot-mini.png"/>
      <param name="CSS_HREF" expression="sun-style.css"/>
    </xslt>

    <!-- NOTE: There is a JavaHelp bug which can result in incomplete
     !   indexing of some input files.  It manifests itself as a message
     !   delivered to stdout: "I/O exception occurred in file 'versions.html'"
     !   (or whichever file is affected).  The Indexer eats the stack
     !   trace unfortunately but it comes down to:
     !     java.lang.ArrayIndexOutOfBoundsException: 256
     !     at com.sun.java.help.search.BitBuffer.concatenate(BitBuffer.java:166)
     !   and I think is the same issue noted at
     !   https://github.com/javaee/javahelp/issues/38
     !   (also labelled java.net JIRA JAVAHELP-38) - looks subtle and
     !   treacherous to try to fix.
     !   It seems(?) to be triggered by large numbers of occurrences of
     !   the same word in one of the HTML files being indexed, e.g. "add"
     !   in versions.html.  Providing the "-nostopwords" flag to the
     !   Indexer invocation seems to make it OK again.  I thought I was
     !   going to have to add the offending word ("add") to the list of
     !   known stop words (run Indexer -h for syntax), but that doesn't
     !   seem to be necessary. -->

    <!-- Builds the help file index database.  Uses the "search-config" file
     !   generated by the toHelp stylesheet, and deletes it when done.
     !   See note above about reported I/O exceptions. -->
    <java classpathref="classpath"
          dir="${build.classes}/uk/ac/starlink/topcat/help"
          fork="true"
          classname="com.sun.java.help.search.Indexer"
          failonerror="yes">
      <arg value="-c"/>
      <arg value="search-config"/>
      <arg value="-nostopwords"/>
    </java>
    <delete file="${build.classes}/uk/ac/starlink/topcat/help/search-config"/>

    <!-- Copy the image icons themselves into the help directory where they
     !   will be referenced from the HTML. -->
    <copy todir="${build.classes}/uk/ac/starlink/topcat/help">
      <fileset dir="${build.docs}/${user.doc}"
               includes="${user.doc}.html sun-style.css"/>
    </copy>
  </target>

  <!--
   !   =================================================
   !   Create user document in PDF form from XML sources
   !   =================================================
   !
   !   The XML document is downconverted to PDF via xsl-fo using Fop.
   !
   !   This process is, for reasons I haven't tried very hard to
   |   understand, rather slow (~3 minutes) and also problematic
   !   in that it can fail due to a Xerces bug in (Sun's) J2SE1.5.
   !   Given that, and the fact that the PDF user document is rather
   !   a special-interest item, this target is no longer invoked as
   !   part of the normal install target.  If the PDF user document
   !   is required, this target must be invoked explicitly.
   !-->
  <target name="docs-pdf"
          depends="build, docs_depend"
          unless="docs.notrequired"
          description="-> creates the user documentation in PDF form">

    <!-- Transform the user document XML to a PDF document via XSL-FO. -->
    <xslt in="${build.docs}/${user.doc}.xml"
          out="${build.docs}/${user.doc}.fo"
          style="${xdoc.etc}/toFo.xslt">
      <param name="VERSION" expression="${version}"/>
      <param name="BASEDIR" expression="${build.docs}/${user.doc}"/>
      <param name="FIGDIR" expression="${build.docs}/figures"/>
      <param name="COVERIMAGE" expression="../multishot.png"/>
    </xslt>
    <java classname="org.apache.fop.apps.Fop"
          failonerror="yes"
          fork="yes"
          maxmemory="512M">
      <classpath>
        <fileset dir="${star.jar.dir}/xdoc" includes="*.jar"/>
      </classpath>
      <sysproperty key="java.awt.headless" value="true"/>

      <!-- This is fiddly.
       !   The version of FOP we're using here (0.20, very old) doesn't
       !   handle PNGs on its own, but can do it with the help of JAI or JIMI.
       !   Trying to do it using JAI fails with various errors
       |   (complains about PNG magic numbers amongst other things).
       !   So we can use JIMI, which is in the XDOC package.  
       !   But, FOP tries JAI in preference to JIMI if both are present
       !   (FOP docs say JAI is faster, though both seem exceedingly slow),
       !   so we have to ensure that JAI is not on the classpath.
       !   Since SoG requires JAI, it is probably in the JDK's
       !   extensions directory.  So here we reset the java.ext.dirs
       !   so that JAI doesn't get picked up.
       !   If we ever upgrade to a later FOP, we can dispense with both JIMI
       !   and these classpath acrobatics. -->
      <sysproperty key="java.ext.dirs" value=""/>
      <arg value="-q"/>
      <arg value="-fo"/> <arg value="${build.docs}/${user.doc}.fo"/>
      <arg value="-pdf"/> <arg value="${build.docs}/${user.doc}.pdf"/>
    </java>
  </target>

  <!-- Checks whether the HTML docs build is up to date. -->
  <target name="html_check" unless="docs.notrequired">
    <uptodate property="docs.notrequired"
              srcfile="${src.docs}/${user.doc}.xml" 
              targetfile="${build.docs}/${user.doc}/${user.doc}.html"/>
  </target>

  <!-- Prepares for document creation.  The XML source document and all
   !   the external entities it requires are copied into the build.docs
   !   directory. -->
  <target name="docs_depend"
          depends="build"
          unless="docs.notrequired">

    <property name="ttools.java" value="${java.dir}/../../../ttools/src/main"/>

    <!-- Make destination directory for built files. -->
    <mkdir dir="${build.docs}"/>

    <!-- Copy required source files there. -->
    <copy todir="${build.docs}">
      <fileset dir="${src.docs}" 
               includes="${user.doc}.xml figures/* multishot.png"/>
      <fileset dir="${build.classes}/uk/ac/starlink/topcat/"
               includes="images/*"/>
      <fileset dir="${xdoc.etc}"
               includes="docs.dtd"/>
    </copy>
    <copy todir="${build.docs}/figures">
      <fileset dir="${plot2.figdir}"
               includesfile="${plot2.figdir}/plot2-figs.lis"/>
    </copy>
    <gunzip src="/usr/share/doc/stilts/jel-javadocs.xml.gz"
            dest="${build.docs}/general-javadocs.xml"/>
    <replace file="${build.docs}/general-javadocs.xml"
	     token="id='uk.ac.starlink.ttools.func."
	     value="id='"/>

    <!-- Write a file containing entity definitions for all the image files
     !   that might be referenced in the user document (this file is 
     !   referenced from within the user document as an external entity).
     !   This JVM needs to be forked in order for the command to run
     !   properly on MacOS X (10.4.9), for reasons I don't really 
     !   understand. -->
    <java classname="uk.ac.starlink.topcat.ResourceIcon" 
          output="${build.docs}/image.defs"
          logerror="true"
          fork="true"
          failonerror="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <classpath refid="classpath"/>
      <arg value="-entities"/>
    </java>

    <!-- Construct XML documentation for the JEL-accessible classes.
     !   This is built using Javadoc, and forms part of the user document. -->
    <javadoc doclet="uk.ac.starlink.topcat.doc.TopcatXmlDoclet"
             docletpathref="docs-classpath"
             failonerror="true"
             public="true"
             additionalparam="-act -o ${build.docs}/activation-javadocs.xml" 
             classpathref="classpath"
             encoding="cp1252">
      <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
        <include name="*.java"/>
        <exclude name="Sog.java"/>
      </fileset>
    </javadoc>
    <javadoc doclet="uk.ac.starlink.topcat.doc.TopcatXmlDoclet"
             docletpathref="docs-classpath"
             failonerror="true"
             public="true"
             additionalparam="-act -headonly -o ${build.docs}/activation-classes-javadocs.xml"
             classpathref="classpath"
             encoding="cp1252">
      <fileset dir="${java.dir}/uk/ac/starlink/topcat/func/" defaultexcludes="yes">
        <include name="*.java"/>
        <exclude name="Sog.java"/>
      </fileset>
    </javadoc>
    <!-- Construct topcat usage message in XML. -->
    <property name="topcat.usage" value="${build.docs}/topcat.usage"/>
    <echo message="&lt;![CDATA[" file="${topcat.usage}" append="no"/>
    <java classname="uk.ac.starlink.topcat.Driver"
          failonerror="yes"
          fork="no"
          output="${topcat.usage}"
          append="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="-help"/>
    </java>
    <echo message="]]&gt;" file="${topcat.usage}" append="yes"/>

  </target>

  <!--
   !   =========================================
   !   Makes the API java source files available
   !   =========================================
   !
   !  The full API documentation is created from all the various
   !  packages (of which this package is just one). This target makes
   !  the source code that should be used in the full public API
   !  available in a special part of the build tree so that it can be
   !  automatically discovered. This method works around two potential
   !  problems, not all source code the in src/main directories should be
   !  in the API docs, and it's not possible to make this distinction
   !  easily outside this package (cannot pass out a fileset), plus
   !  some code is generated, so cannot be located by scanning the
   !  src/main tree. When javadocs can be generated incrementally this
   !  arrangement should be reworked to generate whatever is needed as
   !  part of the javadocs target.
   ! 
   !  Application packages should only make public those parts of
   !  their internal APIs that they are prepared to support. Consider
   !  adding such code to proper class libraries (such as util).
   !-->
  <target name="javadoc-sources"
          description="-> make source files for release API documention">

    <mkdir dir="${build.java}"/>

    <!-- Copy and/or generate the source to be included when creating
     !   the full Starlink API javadocs-->
    <copy todir="${build.java}">
      <fileset dir="${java.dir}" defaultexcludes="yes">
          <exclude name="**/README"/>
      </fileset>
    </copy>

  </target>

  <!--
   !   =================
   !   Compile testcases
   !   =================
   !-->
  <target name="compile-tests"
          depends="build,build_demo"
          if="junit.present">

    <mkdir dir="${build.tests}"/>

    <javac srcdir="${tests.dir}"
           destdir="${build.tests}"
           debug="${debug}"
           encoding="cp1252"
           includeantruntime="false"
           deprecation="${deprecation}" >

      <classpath refid="tests-classpath"/>
      <exclude name="uk/ac/starlink/topcat/DocTest.java"/>
    </javac>

  </target>

  <!--
   !   ============
   !   Run testcase
   !   ============
   !-->
  <target name="test"
          depends="run-tests"
          description="-> run JUnit tests"/>

  <target name="run-tests"
          depends="compile-tests,docs-html"
          if="junit.present">

    <junit printsummary="${junit.summary}" haltonfailure="yes"
           filtertrace="${junit.filtertrace}"
           fork="${junit.fork}">

      <classpath refid="tests-classpath"/>

      <jvmarg value="${junit.assertions}"/>

      <sysproperty key="build.tests" value="${build.tests}"/>
      <sysproperty key="tests-classpath.value"
                   value="${tests-classpath.value}"/>
      <sysproperty key="java.library.path" value="${tests-libpath}"/>
      <sysproperty key="basedir" value="${basedir}"/>
      <sysproperty key="xdoc.etc" value="${xdoc.etc}"/>
      <sysproperty key="java.awt.headless" value="${java.awt.headless}"/>
      <sysproperty key="tests.withnet" value="${tests.withnet}"/>

      <formatter type="brief" usefile="false"/>

      <batchtest>
        <fileset dir="${tests.dir}">
          <include name="**/*Test*"/>
          <exclude name="uk/ac/starlink/topcat/DocTest.java"/>
        </fileset>
      </batchtest>

    </junit>

  </target>

  <target name="run-single-test"
          if="testcase"
          depends="compile-tests,docs-html"
          description="-> runs the single unit test defined in the testcase property">

    <junit printsummary="${junit.summary}"
          haltonfailure="yes"
          fork="${junit.fork}"
          filtertrace="${junit.filtertrace}">

      <sysproperty key="hdx.home" value="${hdx.home}"/>
      <sysproperty key="build.tests" value="${build.tests}"/>
      <sysproperty key="tests-classpath.value"
                   value="${tests-classpath.value}"/>
      <sysproperty key="java.library.path" value="${tests-libpath}"/>
      <sysproperty key="basedir" value="${basedir}"/>
      <sysproperty key="xdoc.etc" value="${xdoc.etc}"/>
      <sysproperty key="java.awt.headless" value="${java.awt.headless}"/>
      <sysproperty key="tests.withnet" value="${tests.withnet}"/>
      <classpath refid="tests-classpath"/>
      <jvmarg value="${junit.assertions}"/>
      <formatter type="plain" usefile="false"/>
      <test name="${testcase}"/>

    </junit>

  </target>

  <!--
   ! Get a DTD for this build file. Documentation suggests may be incomplete!
   !
   ! Use:
   !
   !    <!DOCTYPE project PUBLIC "-//ANT//DTD project//EN" "./project.dtd">
   !
   ! at head of document to include.
   !-->
  <target name="dtd">
     <antstructure output="project.dtd"/>
  </target>

</project>