File: build.xml

package info (click to toggle)
starjava-ttools 3.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 23,000 kB
  • sloc: java: 170,407; xml: 19,593; javascript: 670; python: 641; sh: 107; makefile: 29
file content (1826 lines) | stat: -rw-r--r-- 69,757 bytes parent folder | download | duplicates (2)
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
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
<?xml version="1.0"?>

<!--
 !   TTOOLS build file
 !
 !   This file describes how to build and install TTOOLS
 !   from a source and binary release. TTOOLS is an application
 !   package, i.e. provides user-level commands and interfaces, as
 !   well as an optional 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 TTOOLS:
 !      plot2-examples   -> writes example plot images
 !      build-standalone -> builds stilts.jar
 !      docs-pdf         -> builds sun256.pdf
 !
 !   Authors:
 !      Peter W. Draper (17-SEP-2002)
 !
 !   Version:
 !      $Id$
 !
 !-->

<project name="Build file for TTOOLS" 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="https://docs.oracle.com/javase/8/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 TTOOLS"/>
  <property name="name" value="starlink-ttools"/>
  <property name="version" value="3.5.2"/>

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

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

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

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

  <!-- Local directory and remote URL containing example plot data files.
   !   Note you can override these using system properties -
   !   it may be a good idea to reset plot2.figdata.dir to some
   !   external directory if you have multiple starjava builds. -->
  <property name="plot2.figdata.dir"
            value="${basedir}/plot2data/"/>
  <property name="plot2.figdata.url"
            value="http://www.starlink.ac.uk/stilts/plot2data/"/>

  <!-- 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="src.docs" value="${src.dir}/docs"/>
  <property name="src.docs.examp" value="${src.docs}/examp"/>
  <property name="user.doc" value="sun256"/>
  <property name="coverimage" value="ttools2.png"/>
  <property name="xdoc.etc" value="${src.dir}/etc/xdoc"/>

  <!-- 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"/>

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

  <!-- Directory containing files downloaded at build time. -->
  <property name="src.downloads.dir" value="${src.dir}/downloads"/>

  <!-- 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,**/*.jpg,**/*.jpeg,**/*.ico,**/*.png,**/*.eps*"/>

  <!-- 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.java" value="${build.dir}/java"/>
  <property name="build.etc" value="${build.dir}/etc"/>
  <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.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}"/>

  <!-- Doclet base class used for generating XML and HTML user-facing docs
   !   from classes in uk.ac.starlink.ttools.func.
   !   At Java 8, SunDoclet, based on com.sun.doclet API is required.
   !   The com.sun.doclet API is deprecated at Java 9 and withdrawn at Java 17; 
   !   from Java 9, JdkDoclet, based on jdk.doclet.javadoc API can be used
   !   instead. -->
  <condition property="jdk.isv8">
    <contains string="${java.specification.version}" substring="1.8"/>
  </condition>
  <condition property="jel.doclet"
             value="uk.ac.starlink.ttools.build.SunDoclet"
             else="uk.ac.starlink.ttools.build.JdkDoclet">
    <isset property="jdk.isv8"/>
  </condition>
  <condition property="src.excludes"
             value="uk/ac/starlink/ttools/build/JdkDoclet.java"
             else="uk/ac/starlink/ttools/build/SunDoclet.java">
    <isset property="jdk.isv8"/>
  </condition>

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

  <!-- Installed jar files.
   !
   !   Name all the installed jar files of other packages that we depend on.
   !
   !   When compiling under Java 1.4 these will be used to produce a full
   !   classpath that is equivalent to that generated when these are
   !   referenced as optional bundled packages by the JVM.
   !   When compiling under Java 1.5 (and probably later) this is just
   !   a simple path of these jar files, as the expansion to a full optional
   !   bundled package classpath is performed by the compiler
   !
   !   What that all means is that the manifest classpaths of these jar files
   !   are honoured, the plain compiler pre Java 1.5 didn't do that. When Java
   !   1.4 is no longer used the extclasspath type can be replaced by a simple
   !   path.
   !-->
  <path id="installed.classpath">
    <pathelement location="${star.jar.dir}/starlink-util.jar"/>
    <pathelement location="${star.jar.dir}/starlink-table.jar"/>
    <pathelement location="${star.jar.dir}/starlink-tjoin.jar"/>
    <pathelement location="${star.jar.dir}/starlink-fits.jar"/>
    <pathelement location="${star.jar.dir}/starlink-votable.jar"/>
    <pathelement location="${star.jar.dir}/starlink-pal.jar"/>
    <pathelement location="${star.jar.dir}/starlink-registry.jar"/>
    <pathelement location="${star.jar.dir}/starlink-vo.jar"/>
    <pathelement location="${star.jar.dir}/starlink-task.jar"/>
    <pathelement location="${star.jar.dir}/starlink-tfcat.jar"/>
    <pathelement location="${star.jar.dir}/starlink-dpac.jar"/>
    <pathelement location="${star.jar.dir}/jel.jar"/>
    <pathelement location="${star.jar.dir}/adql.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="${star.jar.dir}/eag-healpix.jar"/>
    <pathelement location="${star.jar.dir}/skyview.jar"/>
    <pathelement location="${star.jar.dir}/itext.jar"/>
    <pathelement location="${star.jar.dir}/net.sourceforge.jlibeps.jar"/>
    <pathelement location="${star.jar.dir}/jlatexmath.jar"/>
    <pathelement location="${star.jar.dir}/jide-oss.jar"/>
    <pathelement location="${star.jar.dir}/json.jar"/>
    <pathelement location="${star.jar.dir}/commons-io.jar"/>
    <pathelement location="${star.jar.dir}/org.jfree.svg.jar"/>
    <pathelement location="${star.jar.dir}/servlet-api.jar"/>
    <pathelement location="/usr/lib/jvm/default-java/lib/tools.jar"/>
  </path>

  <path id="jar.classpath">
    <pathelement location="${dist.lib.pkg}/starlink-util.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-table.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-tjoin.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-fits.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-votable.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-pal.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-registry.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-vo.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-task.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-tfcat.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-topcat.jar"/>
    <pathelement location="${dist.lib.pkg}/starlink-dpac.jar"/>
    <pathelement location="${dist.lib.pkg}/jel.jar"/>
    <pathelement location="${dist.lib.pkg}/adql.jar"/>
    <pathelement location="${dist.lib.pkg}/jsamp.jar"/>
    <pathelement location="${dist.lib.pkg}/fits.jar"/>
    <pathelement location="${dist.lib.pkg}/cds.moc.jar"/>
    <pathelement location="${dist.lib.pkg}/eag-healpix.jar"/>
    <pathelement location="${dist.lib.pkg}/skyview.jar"/>
    <pathelement location="${dist.lib.pkg}/itext.jar"/>
    <pathelement location="${dist.lib.pkg}/net.sourceforge.jlibeps.jar"/>
    <pathelement location="${dist.lib.pkg}/jlatexmath.jar"/>
    <pathelement location="${dist.lib.pkg}/jide-oss.jar"/>
    <pathelement location="${dist.lib.pkg}/json.jar"/>
    <pathelement location="${dist.lib.pkg}/commons-io.jar"/>
    <pathelement location="${dist.lib.pkg}/org.jfree.svg.jar"/>
    <pathelement location="${dist.lib.pkg}/servlet-api.jar"/>
  </path>

  <!-- Local build system jar files.
   !
   !   Name all the jar files of other packages that we depend on, which have
   !   not been installed (should be same packages as in installed.classpath).
   !-->
  <path id="built.jarpath"/>

  <!-- Find all local third party jars files.
   !
   !   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.
   !-->
  <mkdir dir="${src.jars.dir}"/>
  <path id="package.jars">
     <fileset dir="${src.jars.dir}">
        <include name="*.jar"/>
     </fileset>
  </path>

  <!-- Create the local build system CLASSPATH.
   !
   !   Create the classpath used when building this package as part of a full
   !   build system without any dependency on any installed or external jar
   !   files.
   !
   !   Classes compiled in the local build tree will be in the "build/classes"
   !   part of each package. Third party packages, have do not have any source
   !   code, just jar files, will have their jar files in their "dist"
   !   directories (usually lib/{package_name}).
   !
   !   So the full built classpath is created by constructing a path
   !   consisting of:
   !
   !      - all third party jar files in this package
   !      - all build/classes directories in the local build system (these
   !        will have the most recent class files)
   !      - all jar files named in built.jarpath, i.e. named local build
   !        system jar files (these can be normal packages in the "dist" state
   !        or third party packages)
   !      - all jar files in the "dist" directories of all packages in the
   !        local build system (these are necessary to make sure that the jar
   !        files in the previous part have their dependencies fulfilled,
   !        without having them all installed)
   !-->
  <path id="built.classpath">

    <!-- Third party jars held by this package -->
    <path refid="package.jars"/>

    <!-- All classes in the local build system -->
    <dirset dir="${star.build.dir}">
      <include name="*/build/classes"/>
    </dirset>

    <!-- Directly dependent jars in the local build system -->
    <path refid="built.jarpath"/>

    <!-- All "dist" jar files to make sure everything is resolved, including
     !   relative URLs of the local packages, without installation -->
    <fileset dir="${star.build.dir}">
      <include name="*/lib/*/*.jar"/>
    </fileset>

  </path>

  <!-- 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}"/>

  <!-- Create the full CLASSPATH used during compilation.
   !
   !   This is created from the user-defined classpath, followed by the
   !   classpath for building against the local system, followed by the
   !   classpath for building against an installed system.
   !-->
  <path id="classpath">
     <path refid="local.classpath"/>
     <path refid="built.classpath"/>
     <path refid="installed.classpath"/>
  </path>

  <!-- Create the JUnit tests CLASSPATH.
   !
   !   Note that in addition to the build/classes and build/tests directory
   !   we also add tests.dir and tests.etc.dir so that resources may be
   !   located there. The full classpath is also used.
   !-->
 <path id="tests-classpath">
    <pathelement location="${star.jar.dir}/junit.jar"/>
    <pathelement location="${star.jar.dir}/healpix.jar"/>
    <pathelement location="${star.jar.dir}/jython.jar"/>
    <pathelement location="${build.classes}"/>
    <pathelement location="${build.tests}"/>
    <pathelement location="${tests.dir}"/>
    <pathelement location="${tests.etc.dir}"/>
    <pathelement location="${build.etc}"/>
    <path refid="classpath"/>
    <pathelement location="${star.jar.dir}/${name}.jar"/>
  </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
   !    =========================================
   !
   !    Minimalist check of the required dependencies so that the build will
   !    not proceed if some basic dependencies are not present on the
   !    classpath. Optional components could also be checked here.
   !-->
  <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"/>

    <!-- 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>

    <!-- 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}">
      <compilerarg value="-Xlint:all,-path,-serial"/>

      <classpath refid="classpath"/>

      <!-- Exclude any files in the source tree that should not be
       !   compiled -->
      <include name="**/*.java"/>
      <exclude name="${src.excludes}"/>
      <exclude name="uk/ac/starlink/ttools/cone/HtmTiling.java"/>
      <exclude name="uk/ac/starlink/ttools/task/StiltsServer.java"/>
      <exclude name="uk/ac/starlink/ttools/server/*.java"/>
      <exclude name="uk/ac/starlink/ttools/mode/PlasticMode.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>

    <!-- Write the package version number to a file. -->
    <echo file="${build.classes}/uk/ac/starlink/ttools/stilts.version"
          message="${version}"/>

    <!-- 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>

    <!-- Additional built resources. -->
    <java classname="uk.ac.starlink.ttools.build.Plot2Example"
          output="${build.classes}/uk/ac/starlink/ttools/server/ex-plots.html"
          failonerror="yes"
          logerror="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <classpath refid="classpath"/>
      <arg value="-mode"/> <arg value="plotserv"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.Plot2Example"
          output="${build.classes}/uk/ac/starlink/ttools/server/basic-plots.html"
          failonerror="yes"
          logerror="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <classpath refid="classpath"/>
      <arg value="-mode"/> <arg value="plotserv_basic"/>
      <arg value="layer-label"/>
      <arg value="skysim"/>
      <arg value="clifford"/>
      <arg value="rampe"/>
      <arg value="layer-function"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.Plot2Example"
          output="${build.classes}/uk/ac/starlink/ttools/server/basic-plots.ipynb"
          failonerror="yes"
          logerror="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <classpath refid="classpath"/>
      <arg value="-mode"/> <arg value="ipynb_basic"/>
      <arg value="layer-label"/>
      <arg value="skysim"/>
      <arg value="clifford"/>
      <arg value="rampe"/>
      <arg value="layer-function"/>
    </java>

    <!-- 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/ttools/func">
          <srcfiles dir="${java.dir}/uk/ac/starlink/ttools/func"/>
        </uptodate>
        <uptodate targetfile="${build.etc}/stilts.py">
          <srcfiles dir="${java.dir}"/>
        </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 JEL-accessible classes. -->
    <mkdir dir="${build.javadocs}"/>
    <javadoc doclet="${jel.doclet}$Html"
             docletpathref="classpath"
             failonerror="true"
             public="true"
             additionalparam="-headings"
             destdir="${build.javadocs}"
             sourcepath="${java.dir}"
             packagenames="uk.ac.starlink.ttools.func"
             classpathref="classpath"
             encoding="cp1252"/>

    <!-- Write and compile JyStilts module source code. -->
    <echo message="Generating stilts.py"/>
    <mkdir dir="${build.etc}"/>
    <java classname="uk.ac.starlink.ttools.build.JyStilts"
          output="${build.etc}/stilts.py"
          failonerror="yes"
          fork="true"
          logerror="yes">
      <classpath refid="classpath"/>
      <sysproperty key="java.awt.headless" value="true"/>
    </java>

    <!-- Write LaTeX fonts resource list. -->
    <echo message="Assembling list of LaTeX fonts"/>
    <mkdir dir="${build.classes}/uk/ac/starlink/ttools/plot2"/>
    <java classname="uk.ac.starlink.ttools.plot.ExternalFontMapper"
          output="${build.classes}/uk/ac/starlink/ttools/plot2/latex_fonts.txt"
          failonerror="yes"
          fork="true"
          logerror="yes">
      <classpath refid="classpath"/>
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="${star.jar.dir}/jlatexmath.jar"/>
    </java>
  </target>

  <target name="build-standalone" depends="install">

    <!-- 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/ttools/revision-string"/>
    <zip destfile="${dist.lib.pkg}/stilts-version.zip">
      <fileset dir="${build.classes}"
               includes="uk/ac/starlink/ttools/revision-string"/>
    </zip>
    <delete file="${build.classes}/uk/ac/starlink/ttools/revision-string"/>

    <java classname="uk.ac.starlink.util.SuperJar" failonerror="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <classpath refid="classpath"/>
      <arg value="-oj"/><arg value="${dist.lib.pkg}/stilts.jar"/>
      <arg value="-oz"/><arg value="${dist.lib.pkg}/stilts_jars.zip"/>
      <arg value="-xjar"/><arg value="junit.jar"/>
      <arg value="-xjar"/><arg value="topcat.jar"/>
      <arg value="-xjar"/><arg value="org.mortbay.jmx.jar"/>
      <arg value="-xjar"/><arg value="jasper-combined.jar"/>
      <arg value="-xjar"/><arg value="parquet-mr-stil.jar"/>
      <arg value="-xent"/><arg value="*"/>
      <arg value="-xent"/><arg value="META-INF/*"/>
      <arg value="-xent"/><arg value="META-INF/maven/"/>
      <arg value="-file"/><arg value="${star.bin}/stilts"/>
      <arg value="-file"/><arg value="${star.etc.pkg}/stilts.py"/>
      <arg value="-file"/><arg value="${src.docs}/LICENSE.txt"/>
      <arg value="-file"/>
          <arg value="${build.classes}/uk/ac/starlink/ttools/stilts.version"/>
      <arg value="${star.lib.pkg}/stilts-app.jar"/>
      <arg value="${dist.lib.pkg}/stilts-version.zip"/>
    </java>
    <delete file="${dist.lib.pkg}/stilts-version.zip"/>
  </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"
          unless="runonly.install"
          description="-> creates the package jar file(s)">

    <!-- Create the library jar file, ttools.jar.
     !   This excludes any GPL-encumbered parts. -->
    <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}"
               excludes="uk/ac/starlink/ttools/gpl/*
                         uk/ac/starlink/ttools/gpl"/>
      <fileset dir="${build.javadocs}"/>
      <fileset dir="${build.etc}"/>
      <manifest>
        <attribute name="Built-By" value="${user.name}"/>
        <attribute name="Class-Path" value="${jar.class.path}"/>
        <attribute name="Main-Class" value="uk.ac.starlink.ttools.Stilts"/>
      </manifest>
    </jar>

    <!-- Create a jar file consisting of just the GPL-encumbered parts. -->
    <mkdir dir="${dist.lib.pkg}"/>
    <jar destfile="${dist.lib.pkg}/${name}-gpl.jar">
      <fileset dir="${build.classes}"
               includes="uk/ac/starlink/ttools/gpl/*"/>
      <manifest> 
        <attribute name="Built-By" value="${user.name}"/>
      </manifest>
    </jar>

    <!-- Also create a jar file which can be used to invoke the STILTS 
     !   application.  As well as a Main-Class, this wants a reference
     !   to the TOPCAT jar file, so that tpipe's topcat output mode can
     !   start up TOPCAT when required.  If you try to put topcat.jar
     !   in the Class-Path entry of the ttools.jar file, it causes part
     !   of the build (or at least the test) to blow up with recursive
     !   classpath trouble, so this jar file contains nothing but a
     !   manifest. -->
    <jar destfile="${dist.lib.pkg}/stilts-app.jar" excludes="**">
      <manifest> 
        <attribute name="Built-By" value="${user.name}"/>
        <attribute name="Class-Path" value="${name}.jar ../topcat/topcat.jar"/>
        <attribute name="Main-Class" value="uk.ac.starlink.ttools.Stilts"/>
      </manifest>
    </jar>

  </target>

  <!--
   !   ========================================
   !   Make package JNLP file for Java webstart
   !   ========================================
   !
   ! The webstart setup for an application requires that it have two
   ! JNLP files. One to describe it as an application and one as a component.
   ! The component form is required if another application wants to use
   ! this application, either directly (by embedding) or just as a
   ! dependency (for contact via webservices). These two functions cannot be
   ! performed in the same two JNLP files.
   !-->
  <target name="webstart"
          description="-> create webstart descriptor files">

    <!-- Create a webstart JNLP file for this application as a component, 
     !   so that may be used by other applications. This goes into "dist.lib".
     !-->
     <jnlp toFile="${dist.lib}/${name}.jnlp" href="${name}.jnlp"
          codebase="${webstart.codebase}">

      <information>
         <title>TTOOLS - auxiliary table manipulation utilities</title>
         <vendor>Starlink UK</vendor>
         <homepage href="${home.page}"/>
         <icon href="${webstart.starlink_logo}"/>
         <description>Starlink TTOOLS - Webstart edition</description>
         <offline_allowed/>
       </information>

       <security>
          <all_permissions/>
       </security>

       <resources>
         <j2se version="1.8+"/>

         <!-- All jar files of this application -->
         <fileset dir="${dist.lib}" includes="**/*.jar **/*.zip"
                  excludes="**/stilts.jar **/stilts-app.jar
                            **/stilts_jars.zip"/>

         <!-- Components that this component depends on (non applications
          !   named in the application jar file class-path). -->
         <extension name="TABLE" href="table.jnlp"/>
         <extension name="TJOIN" href="tjoin.jnlp"/>
         <extension name="FITS" href="fits.jnlp"/>
         <extension name="MIRAGE" href="mirage.jnlp"/>
         <extension name="VOTABLE" href="votable.jnlp"/>
         <extension name="TASK" href="task.jnlp"/>
         <extension name="VO" href="vo.jnlp"/>
         <extension name="PAL" href="pal.jnlp"/>
         <extension name="PLASTIC" href="plastic.jnlp"/>
       </resources>

       <!-- This is a component -->
       <component_desc/>
     </jnlp>

  </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,jars,javadocs,docs,webstart,download"
          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 any startup scripts etc. -->
    <copy todir="${dist.bin.pkg}">
      <fileset dir="${script.dir}" excludes="*.template"/>
    </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="${user.doc}/* *.pdf README.* LICENSE.txt"/>
    </copy>

    <!-- Copy extra files. -->
    <copy todir="${dist.etc.pkg}">
      <fileset dir="${build.etc}"/>
    </copy>
    <copy todir="${dist.lib.pkg}">
      <fileset dir="${src.downloads.dir}">
        <include name="*.jar"/>
      </fileset>
    </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}"/>

  </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}"/>
    <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.bin.pkg}"/>
    <mkdir dir="${star.lib.pkg}"/>
    <mkdir dir="${star.etc.pkg}"/>
    <mkdir dir="${star.docs.pkg}"/>

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

    <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"/>
      </fileset>
    </loggedcopy>
    <echo file="${install.log}" append="true">${star.lib.pkg}
</echo>

    <loggedcopy todir="${star.etc}"
                logfile="${install.log}"
                overwrite="${install.overwrite}"
                logfileAppend="true">
      <fileset dir="${dist.etc}"/>
    </loggedcopy>
    <echo file="${install.log}" append="true">${star.etc.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.bin.pkg}"/>
     <mkdir dir="${dist.lib.pkg}"/>
     <mkdir dir="${dist.docs.pkg}"/>
     <mkdir dir="${dist.etc.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"
             source="${source.version}"
             failonerror="yes"
             classpathref="classpath">
      <arg value="-Xdoclint:all,-missing"/>
      <arg value="-quiet"/>

      <!-- 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/ttools/build"/>
	 <exclude name="uk/ac/starlink/ttools/cone/HtmTiling.java"/>
	 <exclude name="uk/ac/starlink/ttools/task/StiltsServer.java"/>
	 <exclude name="uk/ac/starlink/ttools/server/*.java"/>
	 <exclude name="uk/ac/starlink/ttools/mode/PlasticMode.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><![CDATA[<i>Copyright &#169; ${year} Central Laboratory of the Research Councils. All Rights Reserved.<i>]]></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 documentation from XML sources
   !   =================================================
   !
   !   The XML user document is downconverted to single- 
   !   and multiple-file HTML versions in the docs directory.
   !-->
  <target name="docs"
          depends="build, docs_check"
          unless="docs.notrequired"
          description="-> creates the user documentation">

    <!-- 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"/>
      <fileset dir="${xdoc.etc}" includes="docs.dtd"/>
      <fileset dir="${src.docs}" includes="README.* LICENSE.txt"/>
      <fileset dir="${src.docs.examp}" includes="*.xml"/>
    </copy>
    <copy todir="${build.docs}/${user.doc}">
      <fileset dir="${src.docs.examp}"
               includesfile="${src.docs.examp}/plot-example-files.txt"/>
      <fileset dir="${src.docs.examp}"
               includesfile="${src.docs.examp}/plot2-figs.lis"/>
    </copy>

    <!-- Construct XML documentation for the JEL-accessible classes.
     !   This is built using Javadoc, and forms part of the user document. -->
    <javadoc doclet="${jel.doclet}$Xml"
             docletpathref="classpath"
             failonerror="true"
             public="true"
             additionalparam="-o ${build.docs}/jel-javadocs.xml"
             sourcepath="${java.dir}"
             packagenames="uk.ac.starlink.ttools.func"
             classpathref="classpath"
             source="${source.version}"/>

    <!-- Write an XML file containing usage output for some actual
     !   command invocations. -->
    <java classname="uk.ac.starlink.ttools.build.OutputCapture"
          failonerror="yes"
          fork="no"
          output="${build.docs}/stilts-usage.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="uk.ac.starlink.ttools.Stilts"/>
      <arg value="-help"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.OutputCapture"
          failonerror="yes"
          fork="no"
          output="${build.docs}/tcopy-usage.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="uk.ac.starlink.ttools.Stilts"/>
      <arg value="tcopy"/>
      <arg value="help"/>
    </java>
    <!-- fork="yes" required below else ant confuses JAXP -->
    <java classname="uk.ac.starlink.ttools.build.OutputCapture"
          failonerror="yes"
          fork="yes"
          output="${build.docs}/tcopy-in-usage.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="uk.ac.starlink.ttools.Stilts"/>
      <arg value="tcopy"/>
      <arg value="help=in"/>
    </java>

    <!-- Write XML files containing per-task usage information
     !   for inclusion in the user document. -->
    <java classname="uk.ac.starlink.ttools.build.PurposeWriter"
          failonerror="yes"
          output="${build.docs}/purpose-defs.xml"
          logerror="yes"
          fork="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.UsageWriter"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.LayersWriter"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.FilterDoc"
          failonerror="yes"
          output="${build.docs}/filter-docs.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.ModeDoc"
          failonerror="yes"
          output="${build.docs}/mode-docs.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.PaintModeDoc"
          failonerror="yes"
          output="${build.docs}/paintmode-docs.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.LayerTypeDoc"
          failonerror="yes"
          fork="yes"
          output="${build.docs}/layertype-docs.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.ShapeModeDoc"
          failonerror="yes"
          fork="yes"
          output="${build.docs}/shapemode-docs.xml"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.MiscDoc"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.SchemeDoc"
          output="${build.docs}/scheme-docs.xml"
          failonerror="yes"
          fork="no"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="-stil"/>
      <arg value="-stilts"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.HandlerDoc"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="-files"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.ShaderLegend"
          output="${build.docs}/${user.doc}/colormaps-abs.svg"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="-ncol"/>
      <arg value="3"/>
      <arg value="-abs"/>
    </java>
    <java classname="uk.ac.starlink.ttools.build.ShaderLegend"
          output="${build.docs}/${user.doc}/colormaps-noabs.svg"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          logerror="yes"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="-ncol"/>
      <arg value="3"/>
      <arg value="-noabs"/>
    </java>

    <!-- Write XML files containing MatchEngine usage information
     !   for inclusion in the user document. -->
    <java classname="uk.ac.starlink.ttools.build.MatcherUsage"
          failonerror="yes"
          fork="yes"
          dir="${build.docs}"
          classpathref="classpath">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="sky"/>
      <arg value="skyerr"/>
      <arg value="skyellipse"/>
      <arg value="sky3d"/>
      <arg value="exact"/>
      <arg value="1d"/>
      <arg value="2d"/>
      <arg value="2d_anisotropic"/>
      <arg value="2d_cuboid"/>
      <arg value="2d_err"/>
      <arg value="2d_ellipse"/>
      <arg value="sky+1d"/>
    </java>

    <!-- Copy miscellaneous XML -->
    <copy todir="${build.docs}">
      <fileset dir="${star.build.dir}/votable/src/docs"
               includes="fits-plus.xml"/>
      <fileset dir="${star.build.dir}/fits/src/docs"
               includes="fits-wide.xml"/>
    </copy>

    <!-- Transform the user document XML to a single HTML document. -->
    <mkdir dir="${build.docs}/${user.doc}"/>
    <copy todir="${build.docs}/${user.doc}">
      <fileset dir="${src.docs}" includes="${coverimage}"/>
      <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}"/>
      <param name="BASEDIR" expression="${build.docs}/${user.doc}"/>
      <param name="COVERIMAGE" expression="${coverimage}"/>
      <param name="CSS_HREF" expression="sun-style.css"/>
    </xslt>

    <!-- Transform the user document to a multi-page HTML document. -->
  </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, somewhat slow and also problematic
   !   in that it fails in headless mode when trying to render SVGs.
   !   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="docs"
          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}/${user.doc}.2.html"
          classpath="/usr/share/java/Saxon-HE.jar"
          style="${xdoc.etc}/toHTML.xslt">
      <param name="VERSION" expression="${version}"/>
      <param name="BASEDIR" expression="${build.docs}/${user.doc}"/>
      <param name="FIGDIR" expression="${build.docs}/${user.doc}"/>
      <param name="COVERIMAGE" expression="${coverimage}"/>
      <param name="CSS_HREF" expression="sun-style.css"/>
    </xslt>
  </target>

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

  <!--
   !   =======================
   !   Generates example plots
   !   =======================
   !
   !   This target is not called by any of the standard targets, but may
   !   be invoked by hand to write example plot graphics output files
   !   into the source tree.
   !
   !   These plots are not generated as part of the standard build process
   !   because (a) they are somewhat time-consuming to produce and
   !   (b) they require large binary data input files that ought not to be
   !   checked into the source archive.  But this target should be executed
   !   by hand from time to time (including before a release) when
   !   plotting code might have changed.  The example plots should be
   !   pixel-to-pixel equal unless some plotting behaviour has changed,
   !   i.e. running this target should not generated modified output,
   !   so any discrepancies between old and new graphic output revealed
   !   by this target should be understood before committing modified
   !   versions.
   !-->
  <target name="plot2-examples"
          description="-> generate example graphics for plot2 commands"
          depends="build,plot2-figdata">
    <echo message="Writing plot2 example files to ${src.docs.examp}"/>
    <echo message="Input data from ${plot2.figdata.dir}"/>
    <java classpathref="classpath"
          classname="uk.ac.starlink.ttools.build.Plot2Example"
          failonerror="yes"
          fork="yes">
      <jvmarg value="-enableassertions"/>
      <arg value="-dataDir"/>
      <arg value="${plot2.figdata.dir}"/>
      <arg value="-outDir"/>
      <arg value="${src.docs.examp}"/>
      <arg value="-mode"/>
      <arg value="png"/>
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
  </target>

  <!--
   !  This does the same as plot2-examples but forces (most of) the plotting
   !  execution to be done in parallel - in most cases it's done sequentially
   !  by default because the example plots are non-huge.
   !  This may produce slightly different results for some,
   !  but (unless there is a problem) not most of the plot examples.
   !-->
  <target name="plot2-examples-par"
        description="-> generate example graphics for plot2 commands (parallel)"
          depends="build,plot2-figdata">
    <echo message="Writing plot2 example files to ${src.docs.examp}"/>
    <echo message="Input data from ${plot2.figdata.dir}"/>
    <java classpathref="classpath"
          classname="uk.ac.starlink.ttools.build.Plot2Example"
          failonerror="yes"
          fork="yes">
      <arg value="-forceParallel"/>
      <arg value="-dataDir"/>
      <arg value="${plot2.figdata.dir}"/>
      <arg value="-outDir"/>
      <arg value="${src.docs.examp}"/>
      <arg value="-mode"/>
      <arg value="png"/>
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
  </target>

  <!--
   !   =====================================
   !   Acquires data files for example plots
   !   =====================================
   !
   !   Copies missing data files required for generating plot2 example
   !   graphics from an external URL to a local directory.
   !-->
  <target name="plot2-figdata"
          depends="build">
    <mkdir dir="${plot2.figdata.dir}"/>
    <java classpathref="classpath"
          classname="uk.ac.starlink.ttools.build.Plot2Example"
          failonerror="yes"
          fork="yes">
      <sysproperty key="java.awt.headless" value="true"/>
      <arg value="-dataDir"/>
      <arg value="${plot2.figdata.dir}"/>
      <arg value="-dataUrl"/>
      <arg value="${plot2.figdata.url}"/>
      <arg value="-mode"/>
      <arg value="copydata"/>
    </java>
  </target>

  <!--
   !   ===================================
   !   Generates example plots (old-style)
   !   ===================================
   !
   !   This target is not called by any of the standard targets, but may
   !   be invoked by hand to write example plot files and associated
   !   descriptions into the source tree.  This approach may be changed
   !   at a later date, but for now it's more convenient than generating
   !   these plots at build time, since (a) the plotting is somewhat
   !   time-consuming and (b) some input datasets are large (not ideal for 
   !   checking into source archive).
   !
   !   These examples refer to the old-style plotting framework,
   !   so are more or less obsolete.
   !-->
  <target name="plot-examples"
          description="-> generate example old-style plots (obsolete)"
          depends="build">
    <echo message="Writing plot example files to source dir ${src.docs.examp}"/>
    <java classpathref="classpath"
          dir="${src.docs.examp}"
          classname="uk.ac.starlink.ttools.build.PlotExample"
          failonerror="yes"
          fork="yes">
      <sysproperty key="java.awt.headless" value="true"/>
    </java>
  </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"
          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/ttools/task/TableMatch1Test.java"/>
      <exclude name="uk/ac/starlink/ttools/mode/ReflectionTest.java"/>
      <exclude name="uk/ac/starlink/ttools/DocTest.java"/>
    </javac>

  </target>

  <!--
   !   ==============================
   !   Download external dependencies
   !   ==============================
   !-->
  <property name="jython.lib" value="jython-standalone-2.7.2.jar"/>
  <target name="download">
    <condition property="downloads.present">
      <and>
        <available file="${src.downloads.dir}/${jython.lib}"/>
      </and>
    </condition>
    <antcall target="do-downloads"/>
    <checksum file="${src.downloads.dir}/${jython.lib}" algorithm="MD5"/>
  </target>
  <target name="do-downloads" unless="downloads.present">
    <get src="https://repo1.maven.org/maven2/org/python/jython-standalone/2.7.2/${jython.lib}"
         dest="${src.downloads.dir}/${jython.lib}"/>
  </target>

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

  <target name="run-tests"
          depends="compile-tests"
          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="java.awt.headless" value="${java.awt.headless}"/>
      <sysproperty key="tests.withnet" value="${tests.withnet}"/>
      <sysproperty key="basedir" value="${basedir}"/>
      <sysproperty key="xdoc.etc" value="${xdoc.etc}"/>
      <sysproperty key="plot2.figdata.dir" value="${plot2.figdata.dir}"/>
      <sysproperty key="python.cachedir" value="${build.dir}/tmp"/>
      <sysproperty key="python.path" value="/usr/lib/site-python:/usr/share/jython/Lib"/>

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

      <batchtest>
        <fileset dir="${tests.dir}">
          <include name="**/*Test.java"/>
          <exclude name="**/net_tests/*"/>
          <exclude name="uk/ac/starlink/ttools/task/TableMatch1Test.java"/>
          <exclude name="uk/ac/starlink/ttools/mode/ReflectionTest.java"/>
          <exclude name="uk/ac/starlink/ttools/DocTest.java"/>
        </fileset>
      </batchtest>

    </junit>

  </target>

  <!--
   !   =================
   !   Run network tests
   !   =================
   !-->
  <target name="run-net-tests"
          depends="compile-tests"
          if="junit.present"
          description="-> run network-dependent JUnit tests">
    <junit printsummary="${junit.summary}" haltonfailure="yes"
           filtertrace="${junit.filtertrace}"
           fork="${junit.fork}">
      <classpath refid="tests-classpath"/>
      <jvmarg value="${junit.assertions}"/>
      <sysproperty key="java.awt.headless" value="${java.awt.headless}"/>
      <formatter type="brief" usefile="false"/>
      <batchtest>
        <fileset dir="${tests.dir}">
          <include name="**/net_tests/*Test.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="run-single-test"
          if="testcase"
          depends="compile-tests"
          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="java.awt.headless" value="${java.awt.headless}"/>
      <sysproperty key="tests.withnet" value="${tests.withnet}"/>
      <sysproperty key="basedir" value="${basedir}"/>
      <sysproperty key="xdoc.etc" value="${xdoc.etc}"/>
      <sysproperty key="plot2.figdata.dir" value="${plot2.figdata.dir}"/>

      <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>