File: common-build.xml

package info (click to toggle)
lucene8 8.8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 117,792 kB
  • sloc: java: 701,725; xml: 20,603; python: 2,406; perl: 1,372; cpp: 330; javascript: 188; makefile: 18; sh: 12
file content (2707 lines) | stat: -rw-r--r-- 119,565 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
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
<?xml version="1.0"?>

<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 -->

<project name="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant" 
                       xmlns:ivy="antlib:org.apache.ivy.ant"
                       xmlns:junit4="antlib:com.carrotsearch.junit4"
                       xmlns:jacoco="antlib:org.jacoco.ant"
                       xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">
  <description>
    This file is designed for importing into a main build file, and not intended
    for standalone use.
  </description>

  <dirname file="${ant.file.common}" property="common.dir"/>
  
  <!-- Give user a chance to override without editing this file
      (and without typing -D each time it compiles it -->
  <property file="${user.home}/lucene.build.properties"/>
  <property file="${user.home}/build.properties"/>
  <property file="${common.dir}/build.properties"/>

  <property name="dev-tools.dir" location="${common.dir}/../dev-tools"/>
  <property name="prettify.dir" location="${common.dir}/tools/prettify"/>
  <property name="license.dir" location="${common.dir}/licenses"/>
  <property name="ivysettings.xml" location="${common.dir}/default-nested-ivy-settings.xml"/>

  <tstamp>
    <format property="current.year" pattern="yyyy"/>
    <format property="DSTAMP" pattern="yyyy-MM-dd"/>
    <format property="TSTAMP" pattern="HH:mm:ss"/>
    <!-- datetime format that is safe to treat as part of a dotted version -->
    <format property="dateversion" pattern="yyyy.MM.dd.HH.mm.ss" />
  </tstamp>

  <property name="Name" value="Lucene"/>
  <property name="name" value="${ant.project.name}"/>
  
  <!-- include version number from property file (includes "version.*" properties) -->
  <loadproperties srcFile="${common.dir}/version.properties"/>
  
  <fail message="'version.base' property must be 'x.y.z' (major, minor, bugfix) or 'x.y.z.1/2' (+ prerelease) and numeric only: ${version.base}">
    <condition>
      <not><matches pattern="^\d+\.\d+\.\d+(|\.1|\.2)$" casesensitive="true" string="${version.base}"/></not>
    </condition>
  </fail>

  <fail message="If you pass -Dversion=... to set a release version, it must match &quot;${version.base}&quot;, optionally followed by a suffix (e.g., &quot;-SNAPSHOT&quot;).">
    <condition>
      <not><matches pattern="^\Q${version.base}\E(|\-.*)$" casesensitive="true" string="${version}"/></not>
    </condition>
  </fail>
  
  <fail message="Your ~/.ant/lib folder or the main classpath of Ant contains some version of ASM. Please remove it, otherwise this build can't run correctly.">
    <condition>
      <available classname="org.objectweb.asm.ClassReader"/>
    </condition>
  </fail>

  <property name="year" value="2000-${current.year}"/>
  
  <!-- Lucene modules unfortunately don't have the "lucene-" prefix, so we add it if no prefix is given in $name: -->
  <condition property="final.name" value="${name}-${version}" else="lucene-${name}-${version}">
    <matches pattern="^(lucene|solr)\b" string="${name}"/>
  </condition>

  <!-- we exclude ext/*.jar because we don't want example/lib/ext logging jars on the cp -->
  <property name="common.classpath.excludes" value="**/*.txt,**/*.template,**/*.sha1,**/*.sha512,ext/*.jar" />

  <property name="build.dir" location="build"/>
  <!-- Needed in case a module needs the original build, also for compile-tools to be called from a module -->
  <property name="common.build.dir" location="${common.dir}/build"/>

  <property name="ivy.bootstrap.version" value="2.4.0" /> <!-- UPGRADE NOTE: update disallowed_ivy_jars_regex below -->
  <property name="disallowed_ivy_jars_regex" value="ivy-2\.[0123].*\.jar"/>

  <property name="ivy.default.configuration" value="*"/>

  <!-- Running ant targets in parralel may require this set to false because ivy:retrieve tasks may race with resolve -->
  <property name="ivy.sync" value="true"/>
  <property name="ivy.resolution-cache.dir" location="${common.build.dir}/ivy-resolution-cache"/>
  <property name="ivy.lock-strategy" value="artifact-lock-nio"/>

  <property name="local.caches" location="${common.dir}/../.caches" />
  <property name="tests.cachedir"  location="${local.caches}/test-stats" />
  <property name="tests.cachefile" location="${common.dir}/tools/junit4/cached-timehints.txt" />
  <property name="tests.cachefilehistory" value="10" />

  <path id="junit-path">
    <fileset dir="${common.dir}/test-framework/lib"/>
  </path>

  <!-- default arguments to pass to JVM executing tests -->
  <property name="args" value="-XX:TieredStopAtLevel=1"/>

  <property name="tests.seed" value="" />

  <!-- This is a hack to be able to override the JVM count for special modules that don't like parallel tests: -->
  <property name="tests.jvms" value="auto" />
  <property name="tests.jvms.override" value="${tests.jvms}" />

  <property name="tests.multiplier" value="1" />
  <property name="tests.codec" value="random" />
  <property name="tests.postingsformat" value="random" />
  <property name="tests.docvaluesformat" value="random" />
  <property name="tests.locale" value="random" />
  <property name="tests.timezone" value="random" />
  <property name="tests.directory" value="random" />
  <property name="tests.linedocsfile" value="europarl.lines.txt.gz" />
  <property name="tests.loggingfile" location="${common.dir}/tools/junit4/logging.properties"/>
  <property name="tests.nightly" value="false" />
  <property name="tests.weekly" value="false" />
  <property name="tests.monster" value="false" />
  <property name="tests.slow" value="true" />
  <property name="tests.cleanthreads.sysprop" value="perMethod"/>
  <property name="tests.verbose" value="false"/>
  <property name="tests.infostream" value="${tests.verbose}"/>
  <property name="tests.filterstacks" value="true"/>
  <property name="tests.luceneMatchVersion" value="${version.base}"/>
  <property name="tests.asserts" value="true" />
  <property name="tests.policy" location="${common.dir}/tools/junit4/tests.policy"/>

  <condition property="tests.asserts.bug.jdk8205399" value="-da:java.util.HashMap" else="">
    <!-- LUCENE-8991 / JDK-8205399: HashMap assertion bug until java12-->
    <and>
      <or>
        <contains string="${java.vm.name}" substring="hotspot" casesensitive="false"/>
        <contains string="${java.vm.name}" substring="openjdk" casesensitive="false"/>
        <contains string="${java.vm.name}" substring="jrockit" casesensitive="false"/>
      </or>
      <or>
        <equals arg1="${java.specification.version}" arg2="1.8"/>
        <equals arg1="${java.specification.version}" arg2="9"/>
        <equals arg1="${java.specification.version}" arg2="10"/>
        <equals arg1="${java.specification.version}" arg2="11"/>
      </or>
      <isfalse value="${tests.asserts.hashmap}" />
    </and>
  </condition>
  
  <condition property="tests.asserts.args" value="-ea -esa ${tests.asserts.bug.jdk8205399}" else="">
    <istrue value="${tests.asserts}"/>
  </condition>

  <condition property="tests.heapsize" value="1024M" else="512M">
    <isset property="run.clover"/>
  </condition>
  
  <condition property="tests.clover.args" value="-XX:ReservedCodeCacheSize=192m -Dclover.pertest.coverage=off" else="">
    <isset property="run.clover"/>
  </condition>

  <!-- Override these in your local properties to your desire. -->
  <!-- Show simple class names (no package) in test suites. -->
  <property name="tests.useSimpleNames" value="false" />
  <!-- Max width for class name truncation.  -->
  <property name="tests.maxClassNameColumns" value="10000" />
  <!-- Show suite summaries for tests. -->
  <property name="tests.showSuiteSummary" value="true" />
  <!-- Show timestamps in console test reports. -->
  <property name="tests.timestamps" value="false" />
  <!-- Heartbeat in seconds for reporting long running tests or hung forked JVMs. -->
  <property name="tests.heartbeat" value="60" />

  <!-- Configure test emission to console for each type of status -->
  <property name="tests.showError" value="true" />
  <property name="tests.showFailure" value="true" />
  <property name="tests.showIgnored" value="true" />

  <!-- Display at most this many failures as a summary at the end of junit4 run. -->
  <property name="tests.showNumFailures" value="10" />
  
  <!-- If we detect Java 9+, should we test the patched classes of the
   multi-release JAR or still run with our own classes? -->
  <property name="tests.withJava9Patches" value="true" />

  <property name="javac.deprecation" value="off"/>
  <property name="javac.debug" value="on"/>
  <property name="javac.release" value="8"/>
  <property name="javac.args" value="-Xlint -Xlint:-deprecation -Xlint:-serial"/>
  <property name="javac.profile.args" value="-profile compact2"/>
  <property name="javadoc.link" value="https://docs.oracle.com/javase/8/docs/api/"/>
  <property name="javadoc.link.junit" value="https://junit.org/junit4/javadoc/4.12/"/>
  <property name="javadoc.packagelist.dir" location="${common.dir}/tools/javadoc"/>
  <available file="${javadoc.packagelist.dir}/java8/package-list" property="javadoc.java8.packagelist.exists"/>
  <property name="javadoc.access" value="protected"/>
  <property name="javadoc.charset" value="utf-8"/>
  <property name="javadoc.dir" location="${common.dir}/build/docs"/>
  <property name="javadoc.maxmemory" value="512m" />
  <property name="javadoc.noindex" value="true"/>

  <!---TODO: Fix accessibility (order of H1/H2/H3 headings), see https://issues.apache.org/jira/browse/LUCENE-8729 -->
  <property name="javadoc.doclint.args" value="-Xdoclint:all -Xdoclint:-missing -Xdoclint:-accessibility"/>
  <!---proc:none was added because of LOG4J2-1925 / JDK-8186647 -->
  <property name="javac.doclint.args" value="-Xdoclint:all/protected -Xdoclint:-missing -Xdoclint:-accessibility -proc:none"/>
  
  <!-- Javadoc classpath -->
  <path id="javadoc.classpath">
    <path refid="classpath"/>
    <pathelement location="${ant.home}/lib/ant.jar"/>
    <fileset dir=".">
      <exclude name="build/**/*.jar"/>
      <include name="**/lib/*.jar"/>
    </fileset>
  </path>
  
  <property name="changes.src.dir" location="${common.dir}/site/changes"/>
  <property name="changes.target.dir" location="${common.dir}/build/docs/changes"/>

  <property name="project.name" value="site"/> <!-- todo: is this used by anakia or something else? -->
  <property name="build.encoding" value="utf-8"/>

  <property name="src.dir" location="src/java"/>
  <property name="resources.dir" location="${src.dir}/../resources"/>
  <property name="tests.src.dir" location="src/test"/>
  <available property="module.has.tests" type="dir" file="${tests.src.dir}"/>
  <property name="dist.dir" location="${common.dir}/dist"/>
  <property name="maven.dist.dir" location="${dist.dir}/maven"/>
  <makeurl file="${maven.dist.dir}" property="m2.repository.url" validate="false"/>
  <property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
  <property name="m2.repository.id" value="local"/>
  <property name="m2.credentials.prompt" value="true"/>
  <property name="maven.repository.id" value="remote"/>

  <property name="tests.workDir" location="${build.dir}/test"/>
  <property name="junit.output.dir" location="${build.dir}/test"/>
  <property name="junit.reports" location="${build.dir}/test/reports"/>

  <property name="manifest.file" location="${build.dir}/MANIFEST.MF"/>

  <property name="git.exe" value="git" />
  <property name="perl.exe" value="perl" />

  <!-- we default to python2.7 because not all OSs (e.g. mac) have a python2 link -->
  <property name="python2.exe" value="python2.7" />
  <property name="python3.exe" value="python3" />

  <property name="gpg.exe" value="gpg" />
  <property name="gpg.key" value="CODE SIGNING KEY" />

  <property name="filtered.pom.templates.dir" location="${common.dir}/build/poms"/>

  <property name="clover.db.dir" location="${common.dir}/build/clover/db"/>
  <property name="clover.report.dir" location="${common.dir}/build/clover/reports"/>

  <property name="jacoco.report.dir" location="${common.dir}/build/jacoco"/>

  <property name="pitest.report.dir" location="${common.dir}/build/pitest/${name}/reports"/>
  <property name="pitest.distance" value="0" />
  <property name="pitest.threads" value="2" />
  <property name="pitest.testCases" value="org.apache.*" />
  <property name="pitest.maxMutations" value="0" />
  <property name="pitest.timeoutFactor" value="1.25" />
  <property name="pitest.timeoutConst" value="3000" />
  <property name="pitest.targetClasses" value="org.apache.*" />

  <!-- a reasonable default exclusion set, can be overridden for special cases -->
  <property name="rat.excludes" value="**/TODO,**/*.txt,**/*.iml"/>
  
  <!-- These patterns can be defined to add additional files for checks, relative to module's home dir -->
  <property name="rat.additional-includes" value=""/>
  <property name="rat.additional-excludes" value=""/>

  <propertyset id="uptodate.and.compiled.properties" dynamic="true">
    <propertyref regex=".*\.uptodate$$"/>
    <propertyref regex=".*\.compiled$$"/>
    <propertyref regex=".*\.loaded$$"/>
    <propertyref name="lucene.javadoc.url"/><!-- for Solr -->
    <propertyref name="tests.totals.tmpfile" />
    <propertyref name="git-autoclean.disabled"/>
  </propertyset>

  <patternset id="lucene.local.src.package.patterns"
              excludes="**/pom.xml,**/*.iml,**/*.jar,build/**,dist/**,benchmark/work/**,benchmark/temp/**,tools/javadoc/java8/**"
  />

  <!-- Default exclude sources and javadoc jars from Ivy fetch to save time and bandwidth -->
  <condition property="ivy.exclude.types" 
      value=""
      else="source|javadoc">
    <isset property="fetch.sources.javadocs"/>
  </condition>

  <target name="install-ant-contrib" unless="ant-contrib.uptodate" depends="ivy-availability-check,ivy-fail,ivy-configure">
    <property name="ant-contrib.uptodate" value="true"/>
     <ivy:cachepath organisation="ant-contrib" module="ant-contrib" revision="1.0b3"
       inline="true" conf="master" type="jar" pathid="ant-contrib.classpath"/>
    <taskdef resource="ant-contrib.tasks" classpathref="ant-contrib.classpath"/>
  </target>

  <!-- Check for minimum supported ANT version. -->
  <fail message="Minimum supported ANT version is 1.8.2. Yours: ${ant.version}">
    <condition>
      <not><antversion atleast="1.8.2" /></not>
    </condition>
  </fail>

  <fail message="Cannot run with ANT version 1.10.2 - see https://issues.apache.org/jira/browse/LUCENE-8189">
    <condition>
      <antversion exactly="1.10.2"/>
    </condition>
  </fail>

  <fail message="Minimum supported Java version is 1.8.">
    <condition>
      <not><hasmethod classname="java.util.Arrays" method="parallelSort"/></not>
    </condition>
  </fail>

  <!-- temporary for cleanup of java.specification.version, to be in format "x.y" -->
  <loadresource property="-cleaned.specification.version">
    <propertyresource name="java.specification.version"/>
    <filterchain>
      <tokenfilter>
        <filetokenizer/>
        <replaceregex pattern="^(\d+\.\d+)(|\..*)$" replace="\1" flags="s"/>
      </tokenfilter>
    </filterchain>
  </loadresource>

  <!-- 
    the propery "ant.java.version" is not always correct, depending on used ANT version.
    E.g. Java 8 is only detected in ANT 1.8.3+.
    
    We want to detect here only a limited set of versions and placed in normalized form in ${build.java.runtime},
    every other version is normalized to "unknown":
    - To define a target to be only run on a specific version, add <equals/> condition to one of the supplied versions.
    - To explicitely exclude specific versions (and unknown ones), add a condition to disallow "unknown" and some versions like "1.9"/"9"!
    - For Java 9, be sure to exclude both in custom checks: "9" and "1.9"
    
    TODO: Find a better solution in Ant without scripting to check supported Java versions!
   -->
  <condition property="build.java.runtime" value="${-cleaned.specification.version}" else="unknown">
    <or>
      <equals arg1="${-cleaned.specification.version}" arg2="1.8"/>
      <equals arg1="${-cleaned.specification.version}" arg2="1.9"/>
      <equals arg1="${-cleaned.specification.version}" arg2="9"/>
      <equals arg1="${-cleaned.specification.version}" arg2="10"/>
      <equals arg1="${-cleaned.specification.version}" arg2="11"/>
      <equals arg1="${-cleaned.specification.version}" arg2="12"/>
      <equals arg1="${-cleaned.specification.version}" arg2="13"/>
    </or>
  </condition>
  
  <!--
  <echo message="DEBUG: Cleaned java.specification.version=${-cleaned.specification.version}"/>
  <echo message="DEBUG: Detected runtime: ${build.java.runtime}"/>
  -->
  
  <condition property="documentation-lint.supported">
    <and>
      <or>
        <contains string="${java.vm.name}" substring="hotspot" casesensitive="false"/>
        <contains string="${java.vm.name}" substring="openjdk" casesensitive="false"/>
        <contains string="${java.vm.name}" substring="jrockit" casesensitive="false"/>
      </or>
      <equals arg1="${build.java.runtime}" arg2="1.8"/>
      <!-- TODO: Fix this! For now only run this on 64bit, because jTIDY OOMs with default heap size: -->
      <contains string="${os.arch}" substring="64"/>
    </and>
  </condition>

  <!-- workaround for https://issues.apache.org/bugzilla/show_bug.cgi?id=53347 -->
  <condition property="build.compiler" value="javac1.7">
    <or>
      <antversion exactly="1.8.3" />
      <antversion exactly="1.8.4" />
    </or>
  </condition>

  <target name="-documentation-lint-unsupported" unless="documentation-lint.supported">
    <fail message="Linting documentation HTML is not supported on this Java version (${build.java.runtime}) / JVM (${java.vm.name}).">
      <condition>
        <not><isset property="is.jenkins.build"/></not>
      </condition>
    </fail>
    <echo level="warning" message="WARN: Linting documentation HTML is not supported on this Java version (${build.java.runtime}) / JVM (${java.vm.name}). NOTHING DONE!"/>
  </target>

  <!-- Import custom ANT tasks. -->
  <import file="${common.dir}/tools/custom-tasks.xml" />

  <target name="clean"
    description="Removes contents of build and dist directories">
    <delete dir="${build.dir}"/>
    <delete dir="${dist.dir}"/>
    <delete file="velocity.log"/>
  </target>

  <target name="init" depends="git-autoclean,resolve">
    <!-- currently empty -->
  </target>
  
  <!-- Keep track of GIT branch and do "ant clean" on root folder when changed, to prevent bad builds... -->
  
  <property name="gitHeadFile" location="${common.dir}/../.git/HEAD"/>
  <property name="gitHeadLocal" location="${common.dir}/build/git-HEAD"/>
  <available file="${gitHeadFile}" property="isGitCheckout"/>

  <target name="git-autoclean" depends="-check-git-state,-git-cleanroot,-copy-git-state"/>
  
  <target name="-check-git-state" if="isGitCheckout" unless="git-autoclean.disabled">
    <condition property="gitHeadChanged">
      <and>
        <available file="${gitHeadLocal}"/>
        <not><filesmatch file1="${gitHeadFile}" file2="${gitHeadLocal}"/></not>
      </and>
    </condition>
  </target>

  <target name="-git-cleanroot" depends="-check-git-state" if="gitHeadChanged" unless="git-autoclean.disabled">
    <echo message="Git branch changed, cleaning up for sane build..."/>
    <ant dir="${common.dir}/.." target="clean" inheritall="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
  </target>
  
  <target name="-copy-git-state" if="isGitCheckout" unless="git-autoclean.disabled">
    <mkdir dir="${common.dir}/build"/>
    <copy file="${gitHeadFile}" tofile="${gitHeadLocal}"/>
    <property name="git-autoclean.disabled" value="true"/>
  </target>

  <!-- IVY stuff -->

  <target name="ivy-configure">
     <!-- [DW] ivy loses its configuration for some reason. cannot explain this. if
          you have an idea, fix it.
          unless="ivy.settings.uptodate" -->
    <!-- override: just for safety, should be unnecessary -->
    <!-- <property name="ivy.settings.uptodate" value="true"/> -->
  </target>

  <condition property="ivy.symlink">
    <os family="unix"/>
  </condition>

  <target name="resolve" depends="ivy-availability-check,ivy-configure">
    <!-- todo, make this a property or something. 
         only special cases need bundles -->
    <ivy:retrieve type="jar,bundle,test,test-jar,tests" log="download-only" symlink="${ivy.symlink}"
                  conf="${ivy.default.configuration}" sync="${ivy.sync}"/>
  </target>

  <property name="ivy_install_path" location="${user.home}/.ant/lib" />
  <property name="ivy_bootstrap_url1" value="https://repo1.maven.org/maven2"/>
  <property name="ivy_bootstrap_url2" value="https://repo2.maven.org/maven2"/>
  <property name="ivy_checksum_sha1" value="5abe4c24bbe992a9ac07ca563d5bd3e8d569e9ed"/>

  <target name="ivy-availability-check" unless="ivy.available">
    <path id="disallowed.ivy.jars">
      <fileset dir="${ivy_install_path}">
        <filename regex="${disallowed_ivy_jars_regex}"/>
      </fileset>
    </path>
    <loadresource property="disallowed.ivy.jars.list">
      <string value="${toString:disallowed.ivy.jars}"/>
      <filterchain><tokenfilter><replacestring from="jar:" to="jar, "/></tokenfilter></filterchain>
    </loadresource>
    <condition property="disallowed.ivy.jar.found">
      <resourcecount when="greater" count="0">
        <path refid="disallowed.ivy.jars"/>
      </resourcecount>
    </condition>
    <antcall target="-ivy-fail-disallowed-ivy-version"/>

    <condition property="ivy.available">
      <typefound uri="antlib:org.apache.ivy.ant" name="configure" />
    </condition>
    <antcall target="ivy-fail" />
  </target>

  <target name="-ivy-fail-disallowed-ivy-version" if="disallowed.ivy.jar.found">
    <sequential>
      <echo message="Please delete the following disallowed Ivy jar(s): ${disallowed.ivy.jars.list}"/>
      <fail>Found disallowed Ivy jar(s): ${disallowed.ivy.jars.list}</fail>
    </sequential>
  </target>

  <target name="ivy-fail" unless="ivy.available">
   <echo>
     This build requires Ivy and Ivy could not be found in your ant classpath.

     (Due to classpath issues and the recursive nature of the Lucene/Solr 
     build system, a local copy of Ivy can not be used an loaded dynamically 
     by the build.xml)

     You can either manually install a copy of Ivy ${ivy.bootstrap.version} in your ant classpath:
       http://ant.apache.org/manual/install.html#optionalTasks

     Or this build file can do it for you by running the Ivy Bootstrap target:
       ant ivy-bootstrap     
     
     Either way you will only have to install Ivy one time.

     'ant ivy-bootstrap' will install a copy of Ivy into your Ant User Library:
       ${user.home}/.ant/lib
     
     If you would prefer, you can have it installed into an alternative 
     directory using the "-Divy_install_path=/some/path/you/choose" option, 
     but you will have to specify this path every time you build Lucene/Solr 
     in the future...
       ant ivy-bootstrap -Divy_install_path=/some/path/you/choose
       ...
       ant -lib /some/path/you/choose clean compile
       ...
       ant -lib /some/path/you/choose clean compile

     If you have already run ivy-bootstrap, and still get this message, please 
     try using the "--noconfig" option when running ant, or editing your global
     ant config to allow the user lib to be loaded.  See the wiki for more details:
       http://wiki.apache.org/lucene-java/DeveloperTips#Problems_with_Ivy.3F
    </echo>
    <fail>Ivy is not available</fail>
  </target>

  <target name="ivy-bootstrap" description="Download and install Ivy in the users ant lib dir" 
          depends="-ivy-bootstrap1,-ivy-bootstrap2,-ivy-checksum,-ivy-remove-old-versions"/>

  <!-- try to download from repo1.maven.org -->
  <target name="-ivy-bootstrap1">
    <ivy-download src="${ivy_bootstrap_url1}" dest="${ivy_install_path}"/>
    <available file="${ivy_install_path}/ivy-${ivy.bootstrap.version}.jar" property="ivy.bootstrap1.success" />
  </target> 

  <target name="-ivy-bootstrap2" unless="ivy.bootstrap1.success">
    <ivy-download src="${ivy_bootstrap_url2}" dest="${ivy_install_path}"/>
  </target>

  <target name="-ivy-checksum">
    <checksum file="${ivy_install_path}/ivy-${ivy.bootstrap.version}.jar"
              property="${ivy_checksum_sha1}"
              algorithm="SHA"
              verifyproperty="ivy.checksum.success"/>
    <fail message="Checksum mismatch for ivy-${ivy.bootstrap.version}.jar. Please download this file manually">
      <condition>
        <isfalse value="${ivy.checksum.success}"/>
      </condition>
    </fail>
  </target>
  
  <target name="-ivy-remove-old-versions">
    <delete verbose="true" failonerror="true">
      <fileset dir="${ivy_install_path}">
        <filename regex="${disallowed_ivy_jars_regex}"/>
      </fileset>
    </delete>
  </target>
   
  <macrodef name="ivy-download">
      <attribute name="src"/>
      <attribute name="dest"/>
    <sequential>
      <mkdir dir="@{dest}"/>
      <echo message="installing ivy ${ivy.bootstrap.version} to ${ivy_install_path}"/>
      <get src="@{src}/org/apache/ivy/ivy/${ivy.bootstrap.version}/ivy-${ivy.bootstrap.version}.jar"
           dest="@{dest}/ivy-${ivy.bootstrap.version}.jar" usetimestamp="true" ignoreerrors="true"/>
    </sequential>
  </macrodef>

  <target name="compile-core" depends="init, clover"
          description="Compiles core classes">
    <compile
      srcdir="${src.dir}"
      destdir="${build.dir}/classes/java">
      <classpath refid="classpath"/>
    </compile>

    <!-- Copy the resources folder (if existent) -->
    <copy todir="${build.dir}/classes/java">
      <fileset dir="${resources.dir}" erroronmissingdir="no"/>
    </copy>
  </target>

  <target name="compile" depends="compile-core">
    <!-- convenience target to compile core -->
  </target>

  <!-- Special targets to patch all class files by replacing some method calls with new Java 9 methods: -->
  <target name="-mrjar-classes-uptodate">
    <uptodate property="mrjar-classes-uptodate" targetfile="${build.dir}/patch-mrjar.stamp">
      <srcfiles dir= "${build.dir}/classes/java" includes="**/*.class"/>
    </uptodate>
  </target>
  
  <target xmlns:ivy="antlib:org.apache.ivy.ant" name="patch-mrjar-classes" depends="-mrjar-classes-uptodate,ivy-availability-check,ivy-configure,resolve-groovy,compile-core"
    unless="mrjar-classes-uptodate" description="Patches compiled class files for usage with Java 9 in MR-JAR">
    <loadproperties prefix="ivyversions" srcFile="${common.dir}/ivy-versions.properties"/>
    <ivy:cachepath organisation="org.ow2.asm" module="asm-commons" revision="${ivyversions./org.ow2.asm/asm-commons}"
      inline="true" conf="default" transitive="true" log="download-only" pathid="asm.classpath"/>
    <groovy taskname="patch-cls" classpathref="asm.classpath" src="${common.dir}/tools/src/groovy/patch-mrjar-classes.groovy"/>
    <touch file="${build.dir}/patch-mrjar.stamp"/>
  </target>
  
  <target name="-mrjar-check" depends="patch-mrjar-classes">
    <zipfileset id="mrjar-patched-files" prefix="META-INF/versions/9" dir="${build.dir}/classes/java9" erroronmissingdir="false"/>
    <condition property="has-mrjar-patched-files">
      <resourcecount refid="mrjar-patched-files" when="greater" count="0" />
    </condition>
  </target>
  
  <target name="-mrjar-core" depends="-mrjar-check" if="has-mrjar-patched-files">
    <jarify>
      <filesets>
        <zipfileset refid="mrjar-patched-files"/>
      </filesets>
      <jarify-additional-manifest-attributes>
        <attribute name="Multi-Release" value="true"/>
      </jarify-additional-manifest-attributes>
    </jarify>
  </target>
  
  <target name="-jar-core" depends="-mrjar-check" unless="has-mrjar-patched-files">
    <jarify/>
  </target>
  
  <target name="jar-core" depends="-mrjar-core,-jar-core"/>

  <!-- Packaging targets: -->
  
  <property name="lucene.tgz.file" location="${common.dir}/dist/lucene-${version}.tgz"/>
  <available file="${lucene.tgz.file}" property="lucene.tgz.exists"/>
  <property name="lucene.tgz.unpack.dir" location="${common.build.dir}/lucene.tgz.unpacked"/>
  <patternset id="patternset.lucene.solr.jars">
    <include name="**/lucene-*.jar"/>
    <include name="**/solr-*.jar"/>
  </patternset>
  <available type="dir" file="${lucene.tgz.unpack.dir}" property="lucene.tgz.unpack.dir.exists"/>
  <target name="-ensure-lucene-tgz-exists" unless="lucene.tgz.exists">
    <ant dir="${common.dir}" target="package-tgz" inheritall="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
  </target>
  <target name="-unpack-lucene-tgz" unless="lucene.tgz.unpack.dir.exists">
    <antcall target="-ensure-lucene-tgz-exists" inheritall="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </antcall>
    <mkdir dir="${lucene.tgz.unpack.dir}"/>
    <untar compression="gzip" src="${lucene.tgz.file}" dest="${lucene.tgz.unpack.dir}">
      <patternset refid="patternset.lucene.solr.jars"/>
    </untar>
  </target>
  <property name="dist.jar.dir.prefix" value="${lucene.tgz.unpack.dir}/lucene"/>
  <pathconvert property="dist.jar.dir.suffix">
    <mapper>
      <chainedmapper>
        <globmapper from="${common.dir}*" to="*"/>
        <globmapper from="*build.xml" to="*"/>
      </chainedmapper>
    </mapper>
    <path location="${ant.file}"/>
  </pathconvert>

  <macrodef name="m2-deploy" description="Builds a Maven artifact">
    <element name="artifact-attachments" optional="yes"/>
    <element name="parent-poms" optional="yes"/>
    <element name="credentials" optional="yes"/>
    <attribute name="pom.xml"/>
    <attribute name="jar.file" default="${dist.jar.dir.prefix}-${version}/${dist.jar.dir.suffix}/${final.name}.jar"/>
    <sequential>
      <artifact:install-provider artifactId="wagon-ssh" version="1.0-beta-7">
        <remoteRepository id="${maven.repository.id}" url="${ivy_bootstrap_url1}" />
      </artifact:install-provider>
      <parent-poms/>
      <artifact:pom id="maven.project" file="@{pom.xml}">
        <remoteRepository id="${maven.repository.id}" url="${ivy_bootstrap_url1}" />
      </artifact:pom>
      <artifact:deploy file="@{jar.file}">
        <artifact-attachments/>
        <remoteRepository id="${m2.repository.id}" url="${m2.repository.url}">
          <credentials/>
        </remoteRepository>
        <pom refid="maven.project"/>
      </artifact:deploy>
      <artifact:install file="@{jar.file}">
        <artifact-attachments/>
        <pom refid="maven.project"/>
      </artifact:install>
    </sequential>
  </macrodef>

  <macrodef name="m2-install" description="Installs a Maven artifact into the local repository">
    <element name="parent-poms" optional="yes"/>
    <attribute name="pom.xml"/>
    <attribute name="jar.file" default="${dist.jar.dir.prefix}-${version}/${dist.jar.dir.suffix}/${final.name}.jar"/>
    <sequential>
      <parent-poms/>
      <artifact:pom id="maven.project" file="@{pom.xml}"/>
      <artifact:install file="@{jar.file}">
        <pom refid="maven.project"/>
      </artifact:install>
    </sequential>
  </macrodef>

  <!-- validate maven dependencies -->
  <macrodef name="m2-validate-dependencies">
      <attribute name="pom.xml"/>
      <attribute name="licenseDirectory"/>
      <element name="excludes" optional="true"/>
      <element name="additional-filters" optional="true"/>
    <sequential>
      <artifact:dependencies filesetId="maven.fileset" useScope="test" type="jar">
        <artifact:pom file="@{pom.xml}"/>
        <!-- disable completely, so this has no chance to download any updates from anywhere: -->
        <remoteRepository id="apache.snapshots" url="foobar://disabled/">
          <snapshots enabled="false"/>
          <releases enabled="false"/>
        </remoteRepository>
      </artifact:dependencies>
      <licenses licenseDirectory="@{licenseDirectory}">
        <restrict>
          <fileset refid="maven.fileset"/>
          <rsel:not>
            <excludes/>
          </rsel:not>
        </restrict>
        <licenseMapper>
          <chainedmapper>
            <filtermapper refid="license-mapper-defaults"/>
            <filtermapper>
              <additional-filters/>
            </filtermapper>
          </chainedmapper>
        </licenseMapper>
      </licenses>
    </sequential>
  </macrodef>

  <macrodef name="build-manifest" description="Builds a manifest file">
    <attribute name="title"/>
    <attribute name="implementation.title"/>
    <attribute name="manifest.file" default="${manifest.file}"/>
    <element name="additional-manifest-attributes" optional="true"/>
    <sequential>
      <local name="-checkoutid"/>
      <local name="-giterr"/>
      <local name="checkoutid"/>
      
      <!-- If possible, include the GIT hash into manifest: -->
      <exec dir="." executable="${git.exe}" outputproperty="-checkoutid" errorproperty="-giterr" failifexecutionfails="false">
        <arg value="log"/>
        <arg value="--format=%H"/>
        <arg value="-n"/>
        <arg value="1"/>
      </exec>
      <condition property="checkoutid" value="${-checkoutid}" else="unknown">
        <matches pattern="^[0-9a-z]+$" string="${-checkoutid}" casesensitive="false" multiline="true"/>
      </condition>

      <!-- create manifest: -->
      <manifest file="@{manifest.file}">
        <!--
        http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#JAR%20Manifest
        http://java.sun.com/j2se/1.5.0/docs/guide/versioning/spec/versioning2.html
        http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Package.html
        http://java.sun.com/j2se/1.5.0/docs/api/java/util/jar/package-summary.html
        http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
        -->
        <!-- Don't set 'Manifest-Version' it identifies the version of the
             manifest file format, and should always be 1.0 (the default)

             Don't set 'Created-by' attribute, its purpose is
             to identify the version of java used to build the jar,
             which ant will do by default.

             Ant will happily override these with bogus strings if you
             tell it to, so don't.

             NOTE: we don't use section info because all of our manifest data
             applies to the entire jar/war ... no package specific info.
        -->
        <attribute name="Extension-Name" value="@{implementation.title}"/>
        <attribute name="Specification-Title" value="@{title}"/>
        <!-- spec version must match "digit+{.digit+}*" -->
        <attribute name="Specification-Version" value="${spec.version}"/>
        <attribute name="Specification-Vendor"
                   value="The Apache Software Foundation"/>
        <attribute name="Implementation-Title" value="@{implementation.title}"/>
        <!-- impl version can be any string -->
        <attribute name="Implementation-Version"
                   value="${version} ${checkoutid} - ${user.name} - ${DSTAMP} ${TSTAMP}"/>
        <attribute name="Implementation-Vendor"
                   value="The Apache Software Foundation"/>
        <attribute name="X-Compile-Source-JDK" value="${javac.release}"/>
        <attribute name="X-Compile-Target-JDK" value="${javac.release}"/>
        <additional-manifest-attributes />
      </manifest>
    </sequential>
  </macrodef>
  
  <macrodef name="jarify" description="Builds a JAR file">
    <attribute name="basedir" default="${build.dir}/classes/java"/>
    <attribute name="destfile" default="${build.dir}/${final.name}.jar"/>
    <attribute name="title" default="Lucene Search Engine: ${ant.project.name}"/>
    <attribute name="excludes" default="**/pom.xml,**/*.iml"/>
    <attribute name="metainf.source.dir" default="${common.dir}"/>
    <attribute name="implementation.title" default="org.apache.lucene"/>
    <attribute name="manifest.file" default="${manifest.file}"/>
    <element name="filesets" optional="true"/>
    <element name="jarify-additional-manifest-attributes" optional="true"/>
    <sequential>
      <build-manifest title="@{title}"
                      implementation.title="@{implementation.title}"
                      manifest.file="@{manifest.file}">
        <additional-manifest-attributes>
          <jarify-additional-manifest-attributes />
        </additional-manifest-attributes>
      </build-manifest>
      
      <jar destfile="@{destfile}"
           basedir="@{basedir}"
           manifest="@{manifest.file}"
           excludes="@{excludes}">
        <metainf dir="@{metainf.source.dir}" includes="LICENSE.txt,NOTICE.txt"/>
        <filesets />
      </jar>
    </sequential>
  </macrodef>

  <macrodef name="module-uptodate">
    <attribute name="name"/>
    <attribute name="property"/>
    <attribute name="jarfile"/>
    <attribute name="module-src-name" default="@{name}"/>
    <sequential>
      <uptodate property="@{property}" targetfile="@{jarfile}">
        <srcfiles dir="${common.dir}/@{module-src-name}/src/java" includes="**/*.java"/>
      </uptodate>
    </sequential>
  </macrodef>

  <property name="lucene-core.jar" value="${common.dir}/build/core/lucene-core-${version}.jar"/>
  <target name="check-lucene-core-uptodate" unless="lucene-core.uptodate">
    <uptodate property="lucene-core.uptodate" targetfile="${lucene-core.jar}">
       <srcfiles dir="${common.dir}/core/src/java" includes="**/*.java"/>
    </uptodate>
  </target>
  <target name="jar-lucene-core" unless="lucene-core.uptodate" depends="check-lucene-core-uptodate">
    <ant dir="${common.dir}/core" target="jar-core" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="lucene-core.uptodate" value="true"/>
  </target>
  
  <target name="compile-lucene-core" unless="core.compiled">
    <ant dir="${common.dir}/core" target="compile-core" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="core.compiled" value="true"/>
  </target>

  <target name="check-lucene-core-javadocs-uptodate" unless="core-javadocs.uptodate">
    <uptodate property="core-javadocs.uptodate" targetfile="${common.dir}/build/core/lucene-core-${version}-javadoc.jar">
       <srcfiles dir="${common.dir}/core/src/java" includes="**/*.java"/>
    </uptodate>
  </target>

  <target name="check-lucene-codecs-javadocs-uptodate" unless="codecs-javadocs.uptodate">
    <uptodate property="codecs-javadocs.uptodate" targetfile="${common.dir}/build/codecs/lucene-codecs-${version}-javadoc.jar">
       <srcfiles dir="${common.dir}/codecs/src/java" includes="**/*.java"/>
    </uptodate>
  </target>

  <target name="javadocs-lucene-core" depends="check-lucene-core-javadocs-uptodate" unless="core-javadocs.uptodate">
    <ant dir="${common.dir}/core" target="javadocs" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="core-javadocs.uptodate" value="true"/>
  </target>

  <target name="compile-codecs" unless="codecs.compiled">
    <ant dir="${common.dir}/codecs" target="compile-core" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="codecs.compiled" value="true"/>
  </target>

  <target name="javadocs-lucene-codecs" depends="check-lucene-codecs-javadocs-uptodate" unless="codecs-javadocs.uptodate">
    <ant dir="${common.dir}/codecs" target="javadocs" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="codecs-javadocs.uptodate" value="true"/>
  </target>

  <target name="compile-test-framework" unless="lucene.test.framework.compiled">
    <ant dir="${common.dir}/test-framework" target="compile-core" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="lucene.test.framework.compiled" value="true"/>
  </target>

  <target name="check-lucene-test-framework-javadocs-uptodate" 
          unless="lucene.test.framework-javadocs.uptodate">
    <uptodate property="lucene.test.framework-javadocs.uptodate" 
         targetfile="${common.dir}/build/test-framework/lucene-test-framework-${version}-javadoc.jar">
       <srcfiles dir="${common.dir}/test-framework/src/java" includes="**/*.java"/>
    </uptodate>
  </target>

  <target name="javadocs-test-framework" 
          depends="check-lucene-test-framework-javadocs-uptodate"
          unless="lucene.test.framework-javadocs.uptodate">
    <ant dir="${common.dir}/test-framework" target="javadocs" inheritAll="false">
      <propertyset refid="uptodate.and.compiled.properties"/>
    </ant>
    <property name="lucene.test.framework-javadocs.uptodate" value="true"/>
  </target>

  <target name="compile-tools">
    <ant dir="${common.dir}/tools" target="compile-core" inheritAll="false"/>
  </target>

  <target name="compile-test" depends="compile-core,compile-test-framework">
    <compile-test-macro srcdir="${tests.src.dir}" destdir="${build.dir}/classes/test" test.classpath="test.classpath"/>
  </target>

  <macrodef name="compile-test-macro" description="Compiles junit tests.">
    <attribute name="srcdir"/>
    <attribute name="destdir"/>
    <attribute name="test.classpath"/>
    <attribute name="javac.release" default="${javac.release}"/>
    <sequential>
      <compile
        srcdir="@{srcdir}" 
        destdir="@{destdir}"
        javac.release="@{javac.release}">
        <classpath refid="@{test.classpath}"/>
      </compile>

      <!-- Copy any data files present to the classpath -->
      <copy todir="@{destdir}">
        <fileset dir="@{srcdir}" excludes="**/*.java"/>
      </copy>
    </sequential>
  </macrodef>

  <target name="test-updatecache" description="Overwrite tests' timings cache for balancing." depends="install-junit4-taskdef">
    <touch file="${tests.cachefile}" mkdirs="true" verbose="false" />
    <junit4:mergehints file="${tests.cachefile}" historyLength="${tests.cachefilehistory}">
      <resources>
        <!-- The order is important. Include previous stats first, then append new stats. -->
        <file file="${tests.cachefile}" />
        <fileset dir="${tests.cachedir}">
          <include name="**/*.txt" />
        </fileset>
      </resources>
    </junit4:mergehints>
  </target>

  <!-- Aliases for tests filters -->
  <condition property="tests.class" value="*.${testcase}">
    <isset property="testcase" />
  </condition>
  <condition property="tests.method" value="${testmethod}*">
    <isset property="testmethod" />
  </condition>

  <condition property="tests.showSuccess" value="true" else="false">
    <or>
      <isset property="tests.class" />
      <isset property="tests.method" />
    </or>
  </condition>

  <condition property="tests.showOutput" value="always" else="onerror">
    <or>
      <isset property="tests.class" />
      <isset property="tests.method" />
      <istrue value="${tests.showSuccess}"/>
    </or>
  </condition>

  <!-- Test macro using junit4. -->
  <macrodef name="test-macro" description="Executes junit tests.">
    <attribute name="junit.output.dir" default="${junit.output.dir}"/>
    <attribute name="junit.classpath" default="junit.classpath"/>
    <attribute name="testsDir" default="${build.dir}/classes/test"/>
    <attribute name="workDir" default="${tests.workDir}"/>
    <attribute name="threadNum" default="1"/>
    <attribute name="tests.nightly" default="${tests.nightly}"/>
    <attribute name="tests.weekly" default="${tests.weekly}"/>
    <attribute name="tests.monster" default="${tests.monster}"/>
    <attribute name="tests.slow" default="${tests.slow}"/>
    <attribute name="tests.multiplier" default="${tests.multiplier}"/>
    <attribute name="additional.vm.args" default=""/>
    <!-- note this enables keeping junit4 files only (not test temp files) -->
    <attribute name="runner.leaveTemporary" default="false"/>
      
    <sequential>
        <!-- Warn if somebody uses removed properties. -->
        <fail message="This property has been removed: tests.iter, use -Dtests.iters=N.">
          <condition>
            <isset property="tests.iter" />
          </condition>
        </fail>
        <!-- this combo makes no sense LUCENE-4146 -->
        <fail message="You are attempting to use 'tests.iters' in combination with a 'tests.method' value with does not end in a '*' -- This combination makes no sense, because the 'tests.method' filter will be unable to match the synthetic test names generated by the multiple iterations.">
          <condition>
            <and>
              <isset property="tests.iters" />
              <isset property="tests.method" />
              <not>
                <matches pattern="\*$" string="${tests.method}" />
              </not>
            </and>
          </condition>
        </fail>

        <!-- Defaults. -->
        <property name="tests.class"  value="" />
        <property name="tests.method" value="" />
        <property name="tests.dynamicAssignmentRatio" value="0.50" /> <!-- 50% of suites -->
        <property name="tests.haltonfailure" value="true" />
        <property name="tests.leaveTemporary" value="false" />
        <!-- 
           keep junit4 runner files or not (independent of keeping test output files)
         -->
        <condition property="junit4.leaveTemporary">
          <or>
            <istrue value="${tests.leaveTemporary}"/> 
            <istrue value="@{runner.leaveTemporary}"/> 
          </or>
        </condition>
        <property name="tests.iters" value="" />
        <property name="tests.dups"  value="1" />
        <property name="tests.useSecurityManager"  value="true" />

        <property name="tests.heapdump.args" value=""/>

        <!-- turn on security manager? -->
        <condition property="java.security.manager" value="org.apache.lucene.util.TestSecurityManager">
          <istrue value="${tests.useSecurityManager}"/>
        </condition>
        
        <!-- additional arguments for Java 9+ -->
        <local name="tests.runtimespecific.args"/>
        <condition property="tests.runtimespecific.args" value="" else="--illegal-access=deny">
          <equals arg1="${build.java.runtime}" arg2="1.8"/>
        </condition>

        <!-- create a fileset pattern that matches ${tests.class}. -->
        <loadresource property="tests.explicitclass" quiet="true">
          <propertyresource name="tests.class" />
          <filterchain>
            <tokenfilter>
              <filetokenizer/>
              <replacestring from="." to="/"/>
              <replacestring from="*" to="**"/>
              <replaceregex pattern="$" replace=".class" />
            </tokenfilter>
          </filterchain>
        </loadresource>

        <!-- Pick the random seed now (unless already set). -->
        <junit4:pickseed property="tests.seed" />

        <!-- Pick file.encoding based on the random seed. -->
        <junit4:pickfromlist property="tests.file.encoding" allowundefined="false" seed="${tests.seed}">
            <!-- Guaranteed support on any JVM. -->
            <value>US-ASCII</value>   <!-- single byte length -->
            <value>ISO-8859-1</value> <!-- single byte length -->
            <value>UTF-8</value>      <!-- variable byte length -->
            <value><!-- empty/ default encoding. --></value>

            <!--
            Disabled because of Java 1.8 bug on Linux/ Unix:
            http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7181721

            <value>UTF-16</value>     
            <value>UTF-16LE</value>   
            <value>UTF-16BE</value>
            -->
        </junit4:pickfromlist>

        <!-- junit4 does not create this directory. TODO: is this a bug / inconsistency with dir="..."? -->
        <mkdir dir="@{workDir}/temp" />

        <!-- Local test execution statistics from defaults or local caches, if present. -->
        <local name="tests.caches" />
        <available file="${tests.cachedir}/${name}" type="dir" property="tests.caches" value="${tests.cachedir}/${name}" />
        <property name="tests.caches" location="${common.dir}/tools/junit4" /> <!-- defaults -->
        <mkdir dir="${tests.cachedir}/${name}" />

        <local name="junit4.stats.nonIgnored" />

        <junit4:junit4
            taskName="junit4"
            dir="@{workDir}"
            tempdir="@{workDir}/temp"
            maxmemory="${tests.heapsize}"

            statsPropertyPrefix="junit4.stats"

            parallelism="@{threadNum}"

            printSummary="true"
            haltonfailure="${tests.haltonfailure}" 
            failureProperty="tests.failed"

            dynamicAssignmentRatio="${tests.dynamicAssignmentRatio}"
            shuffleOnSlave="true"
            leaveTemporary="${junit4.leaveTemporary}"
            seed="${tests.seed}"
            onNonEmptyWorkDirectory="wipe"

            heartbeat="${tests.heartbeat}"
            uniqueSuiteNames="false"
            
            debugstream="false"
        >
            <!-- Classpaths. -->
            <classpath refid="@{junit.classpath}"/>
            <classpath refid="clover.classpath" />

            <!-- JVM arguments and system properties. -->
            <jvmarg line="${args}"/>
            <jvmarg line="${tests.heapdump.args}"/>
            <jvmarg line="${tests.clover.args}"/>
            <jvmarg line="@{additional.vm.args}"/>
            <jvmarg line="${tests.asserts.args}"/>
            <jvmarg line="${tests.runtimespecific.args}"/>

            <!-- set the number of times tests should run -->
            <sysproperty key="tests.iters" value="${tests.iters}"/>
            <!-- allow tests to control debug prints -->
            <sysproperty key="tests.verbose" value="${tests.verbose}"/>
            <!-- even more debugging -->
            <sysproperty key="tests.infostream" value="${tests.infostream}"/>
            <!-- set the codec tests should run with -->
            <sysproperty key="tests.codec" value="${tests.codec}"/>
            <!-- set the postingsformat tests should run with -->
            <sysproperty key="tests.postingsformat" value="${tests.postingsformat}"/>
            <!-- set the docvaluesformat tests should run with -->
            <sysproperty key="tests.docvaluesformat" value="${tests.docvaluesformat}"/>
            <!-- set the locale tests should run with -->
            <sysproperty key="tests.locale" value="${tests.locale}"/>
            <!-- set the timezone tests should run with -->
            <sysproperty key="tests.timezone" value="${tests.timezone}"/>
            <!-- set the directory tests should run with -->
            <sysproperty key="tests.directory" value="${tests.directory}"/>
            <!-- set the line file source for oal.util.LineFileDocs -->
            <sysproperty key="tests.linedocsfile" value="${tests.linedocsfile}"/>
            <!-- set the Version that tests should run against -->
            <sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
            <!-- for lucene we can be strict, and we don't want false fails even across methods -->
            <sysproperty key="tests.cleanthreads" value="${tests.cleanthreads.sysprop}"/>
            <!-- logging config file -->
            <sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
            <!-- set whether or not nightly tests should run -->
            <sysproperty key="tests.nightly" value="@{tests.nightly}"/>
              <!-- set whether or not weekly tests should run -->
            <sysproperty key="tests.weekly" value="@{tests.weekly}"/>
            <!-- set whether or not monster tests should run -->
            <sysproperty key="tests.monster" value="@{tests.monster}"/>
              <!-- set whether or not slow tests should run -->
            <sysproperty key="tests.slow" value="@{tests.slow}"/>
              
            <!-- set whether tests framework should not require java assertions enabled -->
            <sysproperty key="tests.asserts" value="${tests.asserts}"/>

            <!-- TODO: create propertyset for test properties, so each project can have its own set -->
            <sysproperty key="tests.multiplier" value="@{tests.multiplier}"/>
            
            <!-- Temporary directory a subdir of the cwd. -->
            <sysproperty key="tempDir" value="./temp" />
            <sysproperty key="java.io.tmpdir" value="./temp" />

            <!-- Restrict access to certain Java features and install security manager: -->
            <sysproperty key="common.dir" file="${common.dir}" />
            <sysproperty key="clover.db.dir" file="${clover.db.dir}" />
            <syspropertyset>
                <propertyref prefix="java.security.manager"/>
            </syspropertyset>
            <sysproperty key="java.security.policy" file="${tests.policy}" />

            <sysproperty key="tests.LUCENE_VERSION" value="${version.base}"/>

            <sysproperty key="jetty.testMode" value="1"/>
            <sysproperty key="jetty.insecurerandom" value="1"/>
            <sysproperty key="solr.directoryFactory" value="org.apache.solr.core.MockDirectoryFactory"/>
            
            <!-- disable AWT while running tests -->
            <sysproperty key="java.awt.headless" value="true"/>

            <!-- turn jenkins blood red for hashmap bugs, even on jdk7 -->
            <sysproperty key="jdk.map.althashing.threshold" value="0"/>

            <sysproperty key="tests.src.home" value="${user.dir}" />

            <!-- replaces default random source to the nonblocking variant -->
            <sysproperty key="java.security.egd" value="file:/dev/./urandom"/>

            <!-- Only pass these to the test JVMs if defined in ANT. -->
            <syspropertyset>
                <propertyref prefix="tests.maxfailures" />
                <propertyref prefix="tests.failfast" />
                <propertyref prefix="tests.badapples" />
                <propertyref prefix="tests.bwcdir" />
                <propertyref prefix="tests.timeoutSuite" />
                <propertyref prefix="tests.disableHdfs" />
                <propertyref prefix="tests.filter" />
                <propertyref prefix="tests.awaitsfix" />
                <propertyref prefix="tests.leavetmpdir" />
                <propertyref prefix="tests.leaveTemporary" />
                <propertyref prefix="tests.leavetemporary" />
                <propertyref prefix="solr.test.leavetmpdir" />
                <propertyref prefix="solr.tests.use.numeric.points" />
            </syspropertyset>

            <!-- Pass randomized settings to the forked JVM. -->
            <syspropertyset ignoreEmpty="true">
                <propertyref prefix="tests.file.encoding" />
                <mapper type="glob" from="tests.*" to="*" />
            </syspropertyset>

            <!-- Use static cached test balancing statistics. -->
            <balancers>
                <junit4:execution-times>
                    <fileset dir="${tests.caches}"  includes="**/*.txt" />
                </junit4:execution-times>
            </balancers>            

            <!-- Reporting listeners. -->
            <listeners>
                <!-- A simplified console output (maven-like). -->
                <junit4:report-text
                    showThrowable="true" 
                    showStackTraces="true" 
                    showOutput="${tests.showOutput}" 

                    showStatusOk="${tests.showSuccess}"
                    showStatusError="${tests.showError}"
                    showStatusFailure="${tests.showFailure}"
                    showStatusIgnored="${tests.showIgnored}"

                    showSuiteSummary="${tests.showSuiteSummary}"

                    useSimpleNames="${tests.useSimpleNames}"
                    maxClassNameColumns="${tests.maxClassNameColumns}"
                    
                    timestamps="${tests.timestamps}"
                    showNumFailures="${tests.showNumFailures}">

                  <!-- Filter stack traces. The default set of filters is similar to Ant's (reflection, assertions, junit's own stuff). -->
                  <junit4:filtertrace defaults="true" enabled="${tests.filterstacks}">
                    <!-- Lucene-specific stack frames (test rules mostly). -->
                    <containsstring contains="at com.carrotsearch.randomizedtesting.RandomizedRunner" />
                    <containsstring contains="at org.apache.lucene.util.AbstractBeforeAfterRule" />
                    <containsstring contains="at com.carrotsearch.randomizedtesting.rules." />
                    <containsstring contains="at org.apache.lucene.util.TestRule" />
                    <containsstring contains="at com.carrotsearch.randomizedtesting.rules.StatementAdapter" />
                    <containsstring contains="at com.carrotsearch.randomizedtesting.ThreadLeakControl" />

                    <!-- Add custom filters if you like. Lines that match these will be removed. -->
                    <!--
                    <containsstring contains=".." /> 
                    <containsregex pattern="^(\s+at )(org\.junit\.)" /> 
                    -->
                  </junit4:filtertrace>                    
                </junit4:report-text>

                <!-- Emits full status for all tests, their relative order on forked JVMs. -->
                <junit4:report-text
                    file="@{junit.output.dir}/tests-report.txt"
                    showThrowable="true" 
                    showStackTraces="true" 
                    showOutput="always"

                    showStatusOk="true"
                    showStatusError="true"
                    showStatusFailure="true"
                    showStatusIgnored="true"

                    showSuiteSummary="true"
                    timestamps="true"
                />

                <!-- Emits status on errors and failures only. -->
                <junit4:report-text
                    file="@{junit.output.dir}/tests-failures.txt"
                    showThrowable="true" 
                    showStackTraces="true" 
                    showOutput="onerror" 

                    showStatusOk="false"
                    showStatusError="true"
                    showStatusFailure="true"
                    showStatusIgnored="false"

                    showSuiteSummary="false"
                    timestamps="true"
                />

                <!-- Emit the information about tests timings (could be used to determine
                     the slowest tests or for reuse in balancing). -->
                <junit4:report-execution-times file="${tests.cachedir}/${name}/timehints.txt" historyLength="20" />

                <!-- ANT-compatible XMLs for jenkins records etc. -->
                <junit4:report-ant-xml dir="@{junit.output.dir}" outputStreams="no" ignoreDuplicateSuites="true"/>

                <!-- <junit4:report-json file="@{junit.output.dir}/tests-report-${ant.project.name}/index.html" outputStreams="no" /> -->

            </listeners>

            <!-- Input test classes. -->
            <junit4:duplicate times="${tests.dups}">
              <fileset dir="@{testsDir}">
                <include name="**/Test*.class" />
                <include name="**/*Test.class" />
                <include name="${tests.explicitclass}" if="tests.explicitclass" />
                <exclude name="**/*$*" />
              </fileset>
            </junit4:duplicate>
        </junit4:junit4>

        <!-- Append the number of non-ignored (actually executed) tests. -->
        <echo file="${tests.totals.tmpfile}" append="true" encoding="UTF-8"># module: ${ant.project.name}&#x000a;${junit4.stats.nonIgnored}&#x000a;</echo>
        
        <fail message="Beasting executed no tests (a typo in the filter pattern maybe?)">
          <condition>
            <and>
              <isset property="tests.isbeasting"/>
              <equals arg1="${junit4.stats.nonIgnored}" arg2="0"/>
            </and>
          </condition>
        </fail>

        <!-- Report the 5 slowest tests from this run to the console. -->
        <echo level="info">5 slowest tests:</echo>
        <junit4:tophints max="5">
          <file file="${tests.cachedir}/${name}/timehints.txt" />
        </junit4:tophints>
    </sequential>
  </macrodef>

  <target name="test-times" description="Show the slowest tests (averages)." depends="install-junit4-taskdef">
    <property name="max" value="10" />
    <echo>Showing ${max} slowest tests according to local stats. (change with -Dmax=...).</echo>
    <junit4:tophints max="${max}">
      <fileset dir="${tests.cachedir}" includes="**/*.txt" />
    </junit4:tophints>

    <echo>Showing ${max} slowest tests in cached stats. (change with -Dmax=...).</echo>
    <junit4:tophints max="${max}">
        <fileset dir="${common.dir}/tools/junit4">
          <include name="*.txt" />
        </fileset>
    </junit4:tophints>
  </target>

  <target name="test-help" description="Help on 'ant test' syntax.">
      <echo taskname="help">
#
# Test case filtering. --------------------------------------------
#
# - 'tests.class' is a class-filtering shell-like glob pattern,
#   'testcase' is an alias of "tests.class=*.${testcase}"
# - 'tests.method' is a method-filtering glob pattern.
#   'testmethod' is an alias of "tests.method=${testmethod}*"
#

# Run a single test case (variants)
ant test -Dtests.class=org.apache.lucene.package.ClassName
ant test "-Dtests.class=*.ClassName"
ant test -Dtestcase=ClassName

# Run all tests in a package and sub-packages
ant test "-Dtests.class=org.apache.lucene.package.Test*|org.apache.lucene.package.*Test"

# Run any test methods that contain 'esi' (like: ...r*esi*ze...).
ant test "-Dtests.method=*esi*"

#
# Seed and repetitions. -------------------------------------------
#

# Run with a given seed (seed is a hex-encoded long).
ant test -Dtests.seed=DEADBEEF

# Repeats _all_ tests of ClassName N times. Every test repetition
# will have a different seed. NOTE: does not reinitialize
# between repetitions, use only for idempotent tests.
ant test -Dtests.iters=N -Dtestcase=ClassName

# Repeats _all_ tests of ClassName N times. Every test repetition
# will have exactly the same master (dead) and method-level (beef)
# seed.
ant test -Dtests.iters=N -Dtestcase=ClassName -Dtests.seed=dead:beef

# Repeats a given test N times (note the filters - individual test
# repetitions are given suffixes, ie: testFoo[0], testFoo[1], etc...
# so using testmethod or tests.method ending in a glob is necessary
# to ensure iterations are run).
ant test -Dtests.iters=N -Dtestcase=ClassName -Dtestmethod=mytest
ant test -Dtests.iters=N -Dtestcase=ClassName -Dtests.method=mytest*

# Repeats N times but skips any tests after the first failure or M
# initial failures.
ant test -Dtests.iters=N -Dtests.failfast=yes -Dtestcase=...
ant test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...

# Repeats every suite (class) and any tests inside N times
# can be combined with -Dtestcase or -Dtests.iters, etc.
# Can be used for running a single class on multiple JVMs
# in parallel.
ant test -Dtests.dups=N ...

# Test beasting: Repeats every suite with same seed per class
# (N times in parallel) and each test inside (M times). The whole
# run is repeated (beasting) P times in a loop, with a different
# master seed. You can combine beasting with any other parameter,
# just replace "test" with "beast" and give -Dbeast.iters=P
# (P >> 1).
ant beast -Dtests.dups=N -Dtests.iters=M -Dbeast.iters=P \
  -Dtestcase=ClassName

#
# Test groups. ----------------------------------------------------
#
# test groups can be enabled or disabled (true/false). Default
# value provided below in [brackets].

ant -Dtests.nightly=[false]   - nightly test group (@Nightly)
ant -Dtests.weekly=[false]    - weekly tests (@Weekly)
ant -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
ant -Dtests.badapples=[true]  - flakey tests (@BadApple)
ant -Dtests.slow=[true]       - slow tests (@Slow)

# An alternative way to select just one (or more) groups of tests
# is to use the -Dtests.filter property:

-Dtests.filter="@slow"

# would run only slow tests. 'tests.filter' supports Boolean operators
# 'and, or, not' and grouping, for example:

ant -Dtests.filter="@nightly and not(@awaitsfix or @slow)"

# would run nightly tests but not those also marked as awaiting a fix
# or slow. Note that tests.filter, if present, has a priority over any
# individual tests.* properties.


#
# Load balancing and caches. --------------------------------------
#

# Run sequentially (one slave JVM).
ant -Dtests.jvms=1 test

# Run with more slave JVMs than the default.
# Don't count hypercores for CPU-intense tests.
# Make sure there is enough RAM to handle child JVMs.
ant -Dtests.jvms=8 test

# Use repeatable suite order on slave JVMs (disables job stealing).
ant -Dtests.dynamicAssignmentRatio=0 test

# Update global (versioned!) execution times cache (top level).
ant clean test
ant -f lucene/build.xml test-updatecache

#
# Miscellaneous. --------------------------------------------------
#

# Only run test(s), non-recursively. Faster than "ant test".
# WARNING: Skips jar download and compilation. Clover not supported.
ant test-nocompile
ant -Dtestcase=... test-nocompile

# Run all tests without stopping on errors (inspect log files!).
ant -Dtests.haltonfailure=false test

# Run more verbose output (slave JVM parameters, etc.).
ant -verbose test

# Include additional information like what is printed to 
# sysout/syserr, even if the test passes.
# Enabled automatically when running for a single test case.
ant -Dtests.showSuccess=true test

# Change the default suite timeout to 5 seconds.
ant -Dtests.timeoutSuite=5000! ...

# Display local averaged stats, if any (30 slowest tests).
ant test-times -Dmax=30

# Display a timestamp alongside each suite/ test.
ant -Dtests.timestamps=on ...

# Override forked JVM file.encoding
ant -Dtests.file.encoding=XXX ...

# Don't remove any temporary files under slave directories, even if
# the test passes (any of the following props):
ant -Dtests.leaveTemporary=true
ant -Dtests.leavetmpdir=true
ant -Dsolr.test.leavetmpdir=true

# Do *not* filter stack traces emitted to the console.
ant -Dtests.filterstacks=false

# Skip checking for no-executed tests in modules
ant -Dtests.ifNoTests=ignore ...

# Output test files and reports.
${tests-output}/tests-report.txt    - full ASCII tests report
${tests-output}/tests-failures.txt  - failures only (if any)
${tests-output}/tests-report-*      - HTML5 report with results
${tests-output}/junit4-*.suites     - per-JVM executed suites
                                      (important if job stealing).
      </echo>
  </target>

  <target name="install-junit4-taskdef" depends="ivy-configure">
    <!-- JUnit4 taskdef. -->
    <ivy:cachepath organisation="com.carrotsearch.randomizedtesting" module="junit4-ant" revision="${/com.carrotsearch.randomizedtesting/junit4-ant}"
                   type="jar" inline="true" log="download-only" pathid="path.junit4" />

    <taskdef uri="antlib:com.carrotsearch.junit4">
      <classpath refid="path.junit4" />
    </taskdef>
  </target>

  <target name="test" depends="clover,compile-test,patch-mrjar-classes,install-junit4-taskdef,validate,-init-totals,-test,-check-totals" description="Runs unit tests"/>
  <target name="beast" depends="install-ant-contrib,clover,compile-test,patch-mrjar-classes,install-junit4-taskdef,validate,-init-totals,-beast,-check-totals" description="Runs unit tests in a loop (-Dbeast.iters=n)"/>

  <target name="test-nocompile" depends="-clover.disable,install-junit4-taskdef,-init-totals,-test,-check-totals"
          description="Only runs unit tests.  Jars are not downloaded; compilation is not updated; and Clover is not enabled."/>

  <target name="-jacoco-install">
    <!-- download jacoco from ivy if needed -->
    <ivy:cachepath organisation="org.jacoco" module="org.jacoco.ant" type="jar" inline="true" revision="0.7.4.201502262128"
                   log="download-only" pathid="jacoco.classpath" />

    <!-- install jacoco ant tasks -->
    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
        <classpath refid="jacoco.classpath"/>
    </taskdef>
  </target>

  <target name="-jacoco-test" depends="clover,compile-test,install-junit4-taskdef,validate,-init-totals">
    <!-- hack: ant task computes absolute path, but we need a relative path, so its per-testrunner -->
    <jacoco:agent property="agentvmparam.raw"/>
    <property name="agentvmparam" value="${agentvmparam.raw}destfile=jacoco.db,append=false"/>
  
    <!-- create output dir if needed -->
    <mkdir dir="${junit.output.dir}"/>

    <!-- run tests, with agent vm args, and keep runner files around -->
    <test-macro threadNum="${tests.jvms.override}" additional.vm.args="${agentvmparam}" runner.leaveTemporary="true"/>
  </target>

  <target name="-jacoco-report" depends="-check-totals">
    <property name="jacoco.output.dir" location="${jacoco.report.dir}/${name}"/>
    <!-- try to clean output dir to prevent any confusion -->
    <delete dir="${jacoco.output.dir}" failonerror="false"/>
    <mkdir dir="${jacoco.output.dir}"/>

    <!-- print jacoco reports -->
    <jacoco:report>
      <executiondata>
        <fileset dir="${junit.output.dir}" includes="**/jacoco.db"/>
      </executiondata>
      <structure name="${final.name} JaCoCo coverage report">
        <classfiles>
          <fileset dir="${build.dir}/classes/java"/>
        </classfiles>
        <sourcefiles>
          <fileset dir="${src.dir}"/>
        </sourcefiles>
      </structure>
      <html destdir="${jacoco.output.dir}" footer="Copyright ${year} Apache Software Foundation.  All Rights Reserved."/>
    </jacoco:report>
  </target>

  <target name="jacoco" depends="-jacoco-install,-jacoco-test,-jacoco-report" description="Generates JaCoCo coverage report"/>

  <!-- Run the actual tests (must be wrapped with -init-totals, -check-totals) -->
  <target name="-test">
    <mkdir dir="${junit.output.dir}"/>
    <test-macro threadNum="${tests.jvms.override}" />
  </target>

  <!-- Beast the actual tests (must be wrapped with -init-totals, -check-totals) -->
  <target name="-beast" depends="resolve-groovy,install-ant-contrib">
    <fail message="The Beast only works inside of individual modules (where 'junit.classpath' is defined)">
      <condition>
        <not><isreference refid="junit.classpath"/></not>
      </condition>
    </fail>
    <taskdef name="antcallback" classname="net.sf.antcontrib.logic.AntCallBack" classpathref="ant-contrib.classpath"/>
    <groovy classpathref="ant-contrib.classpath" taskname="beaster" src="${common.dir}/tools/src/groovy/run-beaster.groovy"/>
    <fail message="Fail baby fail" if="groovy.error"/>
  </target>

  <target name="-check-totals" if="tests.totals.toplevel" depends="resolve-groovy">
    <!-- We are concluding a test pass at the outermost level. Sum up all executed tests. -->
    <groovy><![CDATA[
      import org.apache.tools.ant.BuildException;
      
      total = 0;
      statsFile = new File(properties["tests.totals.tmpfile"]);
      statsFile.eachLine("UTF-8", { line ->
        if (line ==~ /^[0-9]+/) {
          total += Integer.valueOf(line);
        }
      });
      statsFile.delete();

      if (total == 0 && !"ignore".equals(project.getProperty("tests.ifNoTests"))) {
        throw new BuildException("Not even a single test was executed (a typo in the filter pattern maybe?).");
      }

      // Interesting but let's keep the build output quiet.
      // task.log("Grand total of all executed tests (including sub-modules): " + total);
    ]]></groovy>
  </target>

  <!-- The groovy dependency is wanted: this is done early before any test or any other submodule is ran, to prevent permgen errors! -->
  <target name="-init-totals" unless="tests.totals.tmpfile" depends="resolve-groovy">
    <mkdir dir="${build.dir}" />
    <tempfile property="tests.totals.tmpfile"
              destdir="${build.dir}"
              prefix=".test-totals-"
              suffix=".tmp"
              deleteonexit="true"
              createfile="true" />
    <property name="tests.totals.toplevel" value="true" />
  </target>

  <!--
   See http://issues.apache.org/jira/browse/LUCENE-721
   -->
  <target name="clover" depends="-clover.disable,-clover.load,-clover.classpath,-clover.setup"/>
  
  <target name="-clover.load" depends="ivy-availability-check,ivy-configure" if="run.clover" unless="clover.loaded">
    <echo>Code coverage with OpenClover enabled.</echo>
    <ivy:cachepath organisation="org.openclover" module="clover" revision="4.2.1"
      inline="true" conf="master" pathid="clover.classpath"/>
    <taskdef resource="cloverlib.xml" classpathref="clover.classpath" />
    <mkdir dir="${clover.db.dir}"/>
    <!-- This is a hack, instead of setting "clover.loaded" to "true", we set it
     to the stringified classpath. So it can be passed down to subants,
     and reloaded by "-clover.classpath" task (see below): -->
    <pathconvert property="clover.loaded" refid="clover.classpath"/>
  </target>
  
  <target name="-clover.classpath" if="run.clover">
    <!-- redefine the clover classpath refid for tests by using the hack above: -->
    <path id="clover.classpath" path="${clover.loaded}"/>
  </target>

  <target name="-clover.setup" if="run.clover">
    <clover-setup initString="${clover.db.dir}/coverage.db" encoding="${build.encoding}">
      <fileset dir="${src.dir}" erroronmissingdir="no"/>
      <testsources dir="${tests.src.dir}" erroronmissingdir="no">
        <exclude name="**/TestOpenNLP*Factory.java"/><!-- https://bitbucket.org/openclover/clover/issues/59 -->
      </testsources>
    </clover-setup>
  </target>

  <target name="-clover.disable" unless="run.clover">
    <!-- define dummy clover path used by junit -->
    <path id="clover.classpath"/>
  </target>

  <target name="pitest" if="run.pitest" depends="compile-test,install-junit4-taskdef,clover,validate"
      description="Run Unit tests using pitest mutation testing. To use, specify -Drun.pitest=true on the command line.">
    <echo>Code coverage with pitest enabled.</echo>
    <ivy:cachepath
        organisation="org.pitest" module="pitest-ant"
        inline="true"
        pathid="pitest.framework.classpath" />
    <pitest-macro />
  </target>

  <target name="generate-test-reports" description="Generates test reports">
    <mkdir dir="${junit.reports}"/>
    <junitreport todir="${junit.output.dir}">
      <!-- this fileset let's the task work for individual modules,
           as well as the project as a whole
       -->
      <fileset dir="${build.dir}">
        <include name="**/test/TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${junit.reports}"/>
    </junitreport>
  </target>

  <target name="jar" depends="jar-core">
    <!-- convenience target to package core JAR -->
  </target>

  <target name="jar-src">
    <sequential>
      <mkdir dir="${build.dir}" />
      <jarify basedir="${src.dir}" destfile="${build.dir}/${final.name}-src.jar">
        <filesets>
          <fileset dir="${resources.dir}" erroronmissingdir="no"/>
        </filesets>
      </jarify>
    </sequential>
  </target>

  <target name="default" depends="jar-core"/>

  <available type="file" file="pom.xml" property="pom.xml.present"/>

  <!-- TODO, this is really unintuitive how we depend on a target that does not exist -->
  <target name="javadocs">
    <fail message="You must redefine the javadocs task to do something!!!!!"/>
  </target>

  <target name="install-maven-tasks" unless="maven-tasks.uptodate" depends="ivy-availability-check,ivy-configure">
    <property name="maven-tasks.uptodate" value="true"/>
    <ivy:cachepath organisation="org.apache.maven" module="maven-ant-tasks" revision="2.1.3"
             inline="true" conf="master" type="jar" pathid="maven-ant-tasks.classpath"/>
    <taskdef resource="org/apache/maven/artifact/ant/antlib.xml" 
             uri="antlib:org.apache.maven.artifact.ant" 
             classpathref="maven-ant-tasks.classpath"/>
  </target>

  <target name="-dist-maven" depends="install-maven-tasks, jar-src, javadocs">
    <sequential>
      <property name="top.level.dir" location="${common.dir}/.."/>
      <pathconvert property="pom.xml">
        <mapper>
          <chainedmapper>
            <globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
            <globmapper from="*build.xml" to="*pom.xml"/>
          </chainedmapper>
        </mapper>
        <path location="${ant.file}"/>
      </pathconvert>
      <m2-deploy pom.xml="${pom.xml}">
        <artifact-attachments>
          <attach file="${build.dir}/${final.name}-src.jar"
                  classifier="sources"/>
          <attach file="${build.dir}/${final.name}-javadoc.jar"
                  classifier="javadoc"/>
        </artifact-attachments>
      </m2-deploy>
    </sequential>
  </target>

  <target name="-install-to-maven-local-repo" depends="install-maven-tasks">
    <sequential>
      <property name="top.level.dir" location="${common.dir}/.."/>
      <pathconvert property="pom.xml">
        <mapper>
          <chainedmapper>
            <globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
            <globmapper from="*build.xml" to="*pom.xml"/>
          </chainedmapper>
        </mapper>
        <path location="${ant.file}"/>
      </pathconvert>
      <artifact:pom id="maven.project" file="${pom.xml}"/>
      <artifact:install file="${dist.jar.dir.prefix}-${version}/${dist.jar.dir.suffix}/${final.name}.jar">
        <pom refid="maven.project"/>
      </artifact:install>
    </sequential>
  </target>

  <target name="-install-src-java-to-maven-local-repo" depends="install-maven-tasks">
    <sequential>
      <property name="top.level.dir" location="${common.dir}/.."/>
      <pathconvert property="pom.xml">
        <mapper>
          <chainedmapper>
            <globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
            <globmapper from="*build.xml" to="*/src/java/pom.xml"/>
          </chainedmapper>
        </mapper>
        <path location="${ant.file}"/>
      </pathconvert>
      <artifact:pom id="maven.project" file="${pom.xml}"/>
      <artifact:install file="${dist.jar.dir.prefix}-${version}/${dist.jar.dir.suffix}/${final.name}.jar">
        <pom refid="maven.project"/>
      </artifact:install>
    </sequential>
  </target>

  <target name="-dist-maven-src-java" depends="install-maven-tasks, jar-src, javadocs">
    <sequential>
      <property name="top.level.dir" location="${common.dir}/.."/>
      <pathconvert property="pom.xml">
        <mapper>
          <chainedmapper>
            <globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
            <globmapper from="*build.xml" to="*/src/java/pom.xml"/>
          </chainedmapper>
        </mapper>
        <path location="${ant.file}"/>
      </pathconvert>
      <m2-deploy pom.xml="${pom.xml}">
        <artifact-attachments>
          <attach file="${build.dir}/${final.name}-src.jar"
                  classifier="sources"/>
          <attach file="${build.dir}/${final.name}-javadoc.jar"
                  classifier="javadoc"/>
        </artifact-attachments>
      </m2-deploy>
    </sequential>
  </target>
  
  <target name="-validate-maven-dependencies.init">
    <!-- find the correct pom.xml path and assigns it to property pom.xml -->
    <property name="top.level.dir" location="${common.dir}/.."/>
    <pathconvert property="maven.pom.xml">
      <mapper>
        <chainedmapper>
          <globmapper from="${top.level.dir}*" to="${filtered.pom.templates.dir}*"/>
          <globmapper from="*build.xml" to="*pom.xml"/>
        </chainedmapper>
      </mapper>
      <path location="${ant.file}"/>
    </pathconvert>
    
    <!-- convert ${version} to be a glob pattern, so snapshot versions are allowed: -->
    <loadresource property="maven.version.glob">
      <propertyresource name="version"/>
      <filterchain>
        <tokenfilter>
          <filetokenizer/>
          <replacestring from="-SNAPSHOT" to="-*"/>
        </tokenfilter>
      </filterchain>
    </loadresource>
  </target>
  
  <target name="-validate-maven-dependencies" depends="-validate-maven-dependencies.init">
    <m2-validate-dependencies pom.xml="${maven.pom.xml}" licenseDirectory="${license.dir}">
      <additional-filters>
        <replaceregex pattern="jetty([^/]+)$" replace="jetty" flags="gi" />
        <replaceregex pattern="slf4j-([^/]+)$" replace="slf4j" flags="gi" />
        <replaceregex pattern="javax\.servlet([^/]+)$" replace="javax.servlet" flags="gi" />
      </additional-filters>
      <excludes>
        <rsel:name name="**/lucene-*-${maven.version.glob}.jar" handledirsep="true"/>
      </excludes>
    </m2-validate-dependencies>
  </target>
  
  <property name="module.dependencies.properties.file" location="${common.build.dir}/module.dependencies.properties"/>

  <target name="-append-module-dependencies-properties">
    <sequential>
      <property name="top.level.dir" location="${common.dir}/.."/>
      <pathconvert property="classpath.list" pathsep="," dirsep="/" setonempty="true">
        <path refid="classpath"/>
        <globmapper from="${top.level.dir}/*" to="*" handledirsep="true"/>
      </pathconvert>
      <pathconvert property="test.classpath.list" pathsep="," dirsep="/" setonempty="true">
        <path refid="test.classpath"/>
        <globmapper from="${top.level.dir}/*" to="*" handledirsep="true"/>
      </pathconvert>
      <echo append="true" file="${module.dependencies.properties.file}">
${ant.project.name}.dependencies=${classpath.list}
${ant.project.name}.test.dependencies=${test.classpath.list}
      </echo>
    </sequential>
  </target>

  <property name="maven.dependencies.filters.file" location="${common.build.dir}/maven.dependencies.filters.properties"/>

  <target name="-get-maven-dependencies" depends="compile-tools,load-custom-tasks">
    <ant dir="${common.dir}/.." target="-append-all-modules-dependencies-properties" inheritall="false"/>
    <get-maven-dependencies-macro
        dir="${common.dir}/.."
        centralized.versions.file="${common.dir}/ivy-versions.properties"
        module.dependencies.properties.file="${module.dependencies.properties.file}"
        maven.dependencies.filters.file="${maven.dependencies.filters.file}"/>
  </target>

  <target name="-get-maven-poms" depends="-get-maven-dependencies">
    <property name="maven-build-dir" location="${common.dir}/../maven-build"/>
    <copy todir="${maven-build-dir}" overwrite="true" encoding="UTF-8">
      <fileset dir="${common.dir}/../dev-tools/maven"/>
      <filterset begintoken="@" endtoken="@">
        <filter token="version" value="${version}"/>
        <filter token="version.base" value="${version.base}"/>
        <filter token="spec.version" value="${spec.version}"/>
      </filterset>
      <filterset>
        <filtersfile file="${maven.dependencies.filters.file}"/>
      </filterset>
      <globmapper from="*.template" to="*"/>
    </copy>
  </target>

  <target name="-filter-pom-templates" depends="-get-maven-dependencies">
    <mkdir dir="${filtered.pom.templates.dir}"/>
    <copy todir="${common.dir}/build/poms" overwrite="true" encoding="UTF-8" filtering="on">
      <fileset dir="${common.dir}/../dev-tools/maven"/>
      <filterset begintoken="@" endtoken="@">
        <filter token="version" value="${version}"/>
      </filterset>
      <filterset>
        <filtersfile file="${maven.dependencies.filters.file}"/>
      </filterset>
      <globmapper from="*.template" to="*"/>
    </copy>
  </target>

  <target name="stage-maven-artifacts">
    <sequential>
      <property name="output.build.xml" location="${build.dir}/stage_maven_build.xml"/>
      <property name="dev-tools.scripts.dir" value="${common.dir}/../dev-tools/scripts"/>
      <fail message="maven.dist.dir '${maven.dist.dir}' does not exist!">
        <condition>
          <not>
            <available file="${maven.dist.dir}" type="dir"/>
          </not>
        </condition>
      </fail>
      <exec dir="." executable="${perl.exe}" failonerror="false" outputproperty="stage.maven.script.output"
        resultproperty="stage.maven.script.success">
        <arg value="-CSD"/>
        <arg value="${dev-tools.scripts.dir}/write.stage.maven.build.xml.pl"/>
        <arg value="${maven.dist.dir}"/>              <!-- Maven distribution artifacts directory -->
        <arg value="${output.build.xml}"/>            <!-- Ant build file to be written -->
        <arg value="${common.dir}/common-build.xml"/> <!-- Imported from the ant file to be written -->
        <arg value="${m2.credentials.prompt}"/>
        <arg value="${m2.repository.id}"/>
      </exec>
      <echo message="${stage.maven.script.output}"/>
      <fail message="maven stage script failed!">
        <condition>
          <not>
            <equals arg1="${stage.maven.script.success}" arg2="0"/>
          </not>
        </condition>
      </fail>
    </sequential>
    <echo>Invoking target stage-maven in ${output.build.xml} now...</echo>
    <ant target="stage-maven" antfile="${output.build.xml}" inheritall="false">
      <property name="m2.repository.id" value="${m2.repository.id}"/>
      <property name="m2.repository.url" value="${m2.repository.url}"/>
    </ant>
  </target>

  <target name="rat-sources-typedef" unless="rat.loaded" depends="ivy-availability-check,ivy-configure">
    <ivy:cachepath organisation="org.apache.rat" module="apache-rat" revision="0.11" transitive="false" inline="true" conf="master" type="jar" pathid="rat.classpath"/>
    <typedef resource="org/apache/rat/anttasks/antlib.xml" uri="antlib:org.apache.rat.anttasks" classpathref="rat.classpath"/>
    <property name="rat.loaded" value="true"/>
  </target>

  <target name="rat-sources" depends="rat-sources-typedef"
    description="runs the tasks over source and test files">
    <!-- create a temp file for the log to go to -->
    <tempfile property="rat.sources.logfile"
              prefix="rat"
              destdir="${java.io.tmpdir}"/>
    <!-- run rat, going to the file -->
    <rat:report xmlns:rat="antlib:org.apache.rat.anttasks" 
                reportFile="${rat.sources.logfile}" addDefaultLicenseMatchers="true">
      <fileset dir="." includes="*.xml ${rat.additional-includes}" excludes="${rat.additional-excludes}"/>
      <fileset dir="${src.dir}" excludes="${rat.excludes}" erroronmissingdir="false"/>
      <fileset dir="${tests.src.dir}" excludes="${rat.excludes}" erroronmissingdir="false"/>

      <!-- TODO: Check all resource files. Currently not all stopword and similar files have no header! -->
      <fileset dir="${resources.dir}" includes="META-INF/**" erroronmissingdir="false"/>
      
      <!-- BSD 4-clause stuff (is disallowed below) -->
      <rat:substringMatcher licenseFamilyCategory="BSD4 "
             licenseFamilyName="Original BSD License (with advertising clause)">
        <pattern substring="All advertising materials"/>
      </rat:substringMatcher>

      <!-- BSD-like stuff -->
      <rat:substringMatcher licenseFamilyCategory="BSD  "
             licenseFamilyName="Modified BSD License">
      <!-- brics automaton -->
        <pattern substring="Copyright (c) 2001-2009 Anders Moeller"/>
      <!-- snowball -->
        <pattern substring="Copyright (c) 2001, Dr Martin Porter"/>
      <!-- UMASS kstem -->
        <pattern substring="THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF MASSACHUSETTS AND OTHER CONTRIBUTORS"/>
      <!-- Egothor -->
        <pattern substring="Egothor Software License version 1.00"/>
      <!-- JaSpell -->
        <pattern substring="Copyright (c) 2005 Bruno Martins"/>
      <!-- d3.js -->
        <pattern substring="THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"/>
      <!-- highlight.js -->
        <pattern substring="THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS"/>
      </rat:substringMatcher>

      <!-- MIT-like -->
      <rat:substringMatcher licenseFamilyCategory="MIT  "
             licenseFamilyName="The MIT License">
      <!-- ICU license -->
        <pattern substring="Permission is hereby granted, free of charge, to any person obtaining a copy"/>
      </rat:substringMatcher>

      <!-- Apache -->
      <rat:substringMatcher licenseFamilyCategory="AL   "
             licenseFamilyName="Apache">
        <pattern substring="Licensed to the Apache Software Foundation (ASF) under"/>
        <!-- this is the old-school one under some files -->
        <pattern substring="Licensed under the Apache License, Version 2.0 (the &quot;License&quot;)"/>
      </rat:substringMatcher>

      <rat:substringMatcher licenseFamilyCategory="GEN  "
             licenseFamilyName="Generated">
      <!-- svg files generated by gnuplot -->
        <pattern substring="Produced by GNUPLOT"/>
      <!-- snowball stemmers generated by snowball compiler -->
        <pattern substring="This file was generated automatically by the Snowball to Java compiler"/>
      <!-- parsers generated by antlr -->
        <pattern substring="ANTLR GENERATED CODE"/>
      </rat:substringMatcher>

      <!-- built in approved licenses -->
      <rat:approvedLicense familyName="Apache"/>
      <rat:approvedLicense familyName="The MIT License"/>
      <rat:approvedLicense familyName="Modified BSD License"/>
      <rat:approvedLicense familyName="Generated"/>
    </rat:report>
    <!-- now print the output, for review -->
    <loadfile property="rat.output" srcFile="${rat.sources.logfile}"/>
    <echo taskname="rat">${rat.output}</echo>
    <delete>
      <fileset file="${rat.sources.logfile}">
        <and>
          <containsregexp expression="^0 Unknown Licenses"/>
          <not>
            <containsregexp expression="^\s+!"/>
          </not>
        </and>
      </fileset>
    </delete>
    <!-- fail if we didnt find the pattern -->
    <fail message="Rat problems were found!">
      <condition>
        <available file="${rat.sources.logfile}"/>
      </condition>
    </fail>
  </target>

  <!--+
      | M A C R O S
      +-->
  <macrodef name="compile">
    <attribute name="srcdir"/>
    <attribute name="destdir"/>
    <attribute name="javac.release" default="${javac.release}"/>
    <attribute name="includeantruntime" default="${javac.includeAntRuntime}" />

    <element name="nested" implicit="yes" optional="yes"/>

    <sequential>
      <local name="javac.release.args"/>
      <condition property="javac.release.args" value="-source @{javac.release} -target @{javac.release}" else="--release @{javac.release}">
        <equals arg1="${build.java.runtime}" arg2="1.8"/>
      </condition>
      <mkdir dir="@{destdir}"/>
      <javac
        includeAntRuntime="@{includeantruntime}"
        encoding="${build.encoding}"
        srcdir="@{srcdir}"
        destdir="@{destdir}"
        deprecation="${javac.deprecation}"
        debug="${javac.debug}">
        <nested/>
        <!-- <compilerarg line="-Xmaxwarns 10000000"/>
        <compilerarg line="-Xmaxerrs 10000000"/> -->
        <compilerarg line="${javac.args}"/>
        <compilerarg line="${javac.profile.args}"/>
        <compilerarg line="${javac.release.args}"/>
        <compilerarg line="${javac.doclint.args}"/>
      </javac>
    </sequential>
  </macrodef>

  <!-- ECJ Javadoc linting: -->
  
  <condition property="ecj-javadoc-lint.supported">
    <or>
      <equals arg1="${build.java.runtime}" arg2="1.8"/>
      <equals arg1="${build.java.runtime}" arg2="9"/>
      <equals arg1="${build.java.runtime}" arg2="10"/>
      <equals arg1="${build.java.runtime}" arg2="11"/>
      <equals arg1="${build.java.runtime}" arg2="12"/>
      <equals arg1="${build.java.runtime}" arg2="13"/>
    </or>
  </condition>

  <condition property="ecj-javadoc-lint-tests.supported">
    <and>
      <isset property="ecj-javadoc-lint.supported"/>
      <isset property="module.has.tests"/>
    </and>
  </condition>

  <target name="-ecj-javadoc-lint-unsupported" unless="ecj-javadoc-lint.supported">
    <fail message="Linting documentation with ECJ is not supported on this Java version (${build.java.runtime}).">
      <condition>
        <not><isset property="is.jenkins.build"/></not>
      </condition>
    </fail>
    <echo level="warning" message="WARN: Linting documentation with ECJ is not supported on this Java version (${build.java.runtime}). NOTHING DONE!"/>
  </target>

  <target name="-ecj-javadoc-lint" depends="-ecj-javadoc-lint-unsupported,-ecj-javadoc-lint-src,-ecj-javadoc-lint-tests"/>

  <target name="-ecj-javadoc-lint-src" depends="-ecj-resolve" if="ecj-javadoc-lint.supported">
    <ecj-macro srcdir="${src.dir}" configuration="${common.dir}/tools/javadoc/ecj.javadocs.prefs">
      <classpath refid="classpath"/>
    </ecj-macro>
  </target>

  <target name="-ecj-javadoc-lint-tests" depends="-ecj-resolve" if="ecj-javadoc-lint-tests.supported">
    <ecj-macro srcdir="${tests.src.dir}" configuration="${common.dir}/tools/javadoc/ecj.javadocs.prefs">
      <classpath refid="test.classpath"/>
    </ecj-macro>
  </target>
  
  <target name="-ecj-resolve" unless="ecj.loaded" depends="ivy-availability-check,ivy-configure" if="ecj-javadoc-lint.supported">
    <ivy:cachepath organisation="org.eclipse.jdt" module="ecj" revision="3.19.0"
     inline="true" conf="master" type="jar" pathid="ecj.classpath" />
    <componentdef classname="org.eclipse.jdt.core.JDTCompilerAdapter"
     classpathref="ecj.classpath" name="ecj-component"/>
    <property name="ecj.loaded" value="true"/>
  </target>

  <macrodef name="ecj-macro">
    <attribute name="srcdir"/>
    <attribute name="javac.release" default="${javac.release}"/>
    <attribute name="includeantruntime" default="${javac.includeAntRuntime}" />
    <attribute name="configuration"/>

    <element name="nested" implicit="yes" optional="yes"/>

    <sequential>
      <!-- hack: we can tell ECJ not to create classfiles, but it still creates
           package-info.class files. so redirect output to a tempdir -->
      <tempfile property="ecj.trash.out" destdir="${java.io.tmpdir}" prefix="ecj"/>
      <mkdir dir="${ecj.trash.out}"/>
      <javac
        includeAntRuntime="@{includeantruntime}"
        encoding="${build.encoding}"
        srcdir="@{srcdir}"
        destdir="${ecj.trash.out}"
        source="@{javac.release}"
        target="@{javac.release}"
        taskname="ecj-lint">
        <ecj-component/>
        <nested/>
      <!-- hack: we can't disable classfile creation right now, because we need
           to specify a destination for buggy package-info.class files
        <compilerarg value="-d"/>
        <compilerarg value="none"/> -->
        <compilerarg value="-enableJavadoc"/>
        <compilerarg value="-properties"/>
        <compilerarg value="@{configuration}"/>
      </javac>
      <delete dir="${ecj.trash.out}"/>
    </sequential>
  </macrodef>

  <!-- TODO: if we make a custom ant task, we can give better
       errors and stuff here, and not make a stupid temp dir -->
  <macrodef name="jtidy-macro">
    <element name="nested" implicit="yes" optional="yes"/>
    <sequential>
      <ivy:cachepath organisation="net.sf.jtidy" module="jtidy" revision="r938"
          log="download-only" inline="true" conf="master" type="jar" pathid="jtidy.classpath" />
      <taskdef name="tidy" classname="org.w3c.tidy.ant.JTidyTask" classpathref="jtidy.classpath"/>
      <delete dir="${common.dir}/build/jtidy_tmp" quiet="true"/>
      <echo message="Checking for broken html (such as invalid tags)..." taskname="jtidy"/>
      <tidy failonerror="true" destdir="${common.dir}/build/jtidy_tmp">
         <nested/>
         <parameter name="input-encoding" value="UTF-8" />
         <parameter name="only-errors" value="true" />
         <parameter name="show-warnings" value="false" />
      </tidy>
      <delete dir="${common.dir}/build/jtidy_tmp" quiet="true"/>
    </sequential>
  </macrodef>

  <property name="failonjavadocwarning" value="true"/>
  <macrodef name="invoke-javadoc">
    <element name="sources" optional="yes"/>
    <attribute name="destdir"/>
    <attribute name="title" default="${Name} ${version} API"/>
    <attribute name="overview" default="${src.dir}/overview.html"/>
    <attribute name="linksource" default="no"/>
    <sequential>
      <local name="javadoc.release.args"/>
      <condition property="javadoc.release.args" value="-source ${javac.release}" else="--release ${javac.release}">
        <equals arg1="${build.java.runtime}" arg2="1.8"/>
      </condition>
      <antcall target="download-java8-javadoc-packagelist"/>
      <delete file="@{destdir}/stylesheet.css" failonerror="false"/>
      <delete file="@{destdir}/script.js" failonerror="false"/>
      <record name="@{destdir}/log_javadoc.txt" action="start" append="no"/>
      <javadoc
          overview="@{overview}"
          packagenames="org.apache.lucene.*,org.apache.solr.*"
          destdir="@{destdir}"
          access="${javadoc.access}"
          encoding="${build.encoding}"
          charset="${javadoc.charset}"
          docencoding="${javadoc.charset}"
          noindex="${javadoc.noindex}"
          includenosourcepackages="true"
          author="true"
          version="true"
          linksource="@{linksource}"
          use="true"
          failonerror="true"
          locale="en_US"
          windowtitle="${Name} ${version} API"
          doctitle="@{title}"
          maxmemory="${javadoc.maxmemory}">
        <tag name="lucene.experimental" 
          description="WARNING: This API is experimental and might change in incompatible ways in the next release."/>
        <tag name="lucene.internal"
        description="NOTE: This API is for internal purposes only and might change in incompatible ways in the next release."/>
        <tag name="lucene.spi"
        description="SPI Name (Note: This is case-insensitive. e.g., if the name is 'htmlStrip', 'htmlstrip' can be used when looking up the service):" scope="types"/>
        <link offline="true" packagelistLoc="${javadoc.dir}"/>
        <link offline="true" href="${javadoc.link}" packagelistLoc="${javadoc.packagelist.dir}/java8"/>
        <bottom><![CDATA[
          <i>Copyright &copy; ${year} Apache Software Foundation.  All Rights Reserved.</i>
        ]]></bottom>
        
        <sources />
                
        <classpath refid="javadoc.classpath"/>
        <arg line="${javadoc.release.args}"/>
        <arg line="${javadoc.doclint.args}"/>
        <!-- force locale to be "en_US", as Javadoc tool ignores locale parameter (in some cases) -->
        <arg line="-J-Duser.language=en -J-Duser.country=US"/>
      </javadoc>
      <record name="@{destdir}/log_javadoc.txt" action="stop"/>
      
      <!-- append prettify to scripts and css -->
      <concat destfile="@{destdir}/stylesheet.css" append="true" fixlastline="true" encoding="UTF-8">
        <filelist dir="${prettify.dir}" files="prettify.css"/>
      </concat>
      <concat destfile="@{destdir}/script.js" append="true" fixlastline="true" encoding="UTF-8">
        <filelist dir="${prettify.dir}" files="prettify.js inject-javadocs.js"/>
      </concat>
      <fixcrlf srcdir="@{destdir}" includes="stylesheet.css script.js" eol="lf" fixlast="true" encoding="UTF-8" />

      <delete>
        <fileset file="@{destdir}/log_javadoc.txt">
          <or>
            <not>
              <containsregexp expression="\[javadoc\]\s*[1-9][0-9]*\s*warning"/>
            </not>
            <and>
              <!-- allow 1 warning, if there is also a bootstrap warning generated by Java7 -->
              <containsregexp expression="\[javadoc\]\s*warning.*bootstrap"/>
              <containsregexp expression="\[javadoc\]\s*1\s*warning"/>
            </and>
          </or>
        </fileset>
      </delete>

      <fail message="Javadocs warnings were found!">
        <condition>
          <and>
            <available file="@{destdir}/log_javadoc.txt"/>
            <istrue value="${failonjavadocwarning}"/>
          </and>
        </condition>
      </fail>
   </sequential>
  </macrodef>

  <target name="check-javadocs-uptodate">
    <uptodate property="javadocs-uptodate-${name}" targetfile="${build.dir}/${final.name}-javadoc.jar">
      <srcfiles dir="${src.dir}">
        <include name="**/*.java"/>
        <include name="**/*.html"/>
      </srcfiles>
    </uptodate>
  </target>

  <macrodef name="modules-crawl">
    <attribute name="target" default=""/>
    <attribute name="failonerror" default="true"/>
    <sequential>
      <subant target="@{target}" failonerror="@{failonerror}" inheritall="false">
        <propertyset refid="uptodate.and.compiled.properties"/>
        <fileset dir="." includes="*/build.xml" excludes="build/**,core/**,test-framework/**,tools/**"/>
      </subant>
    </sequential>
  </macrodef>

  <target name="download-java8-javadoc-packagelist" unless="javadoc.java8.packagelist.exists">
    <mkdir dir="${javadoc.packagelist.dir}/java8"/>
    <get src="${javadoc.link}/package-list"
         dest="${javadoc.packagelist.dir}/java8/package-list" ignoreerrors="true"/>
  </target>

  <!-- VALIDATION work -->

  <!-- Generic placeholder target for if we add other validation tasks -->
  <target name="validate">
  </target>

  <property name="src.export.dir" location="${build.dir}/src-export"/>
  <macrodef name="export-source"
            description="Exports the source to src.export.dir.">
    <attribute name="source.dir"/>
    <sequential>
      <delete dir="${src.export.dir}" includeemptydirs="true" failonerror="false"/>
      <exec dir="@{source.dir}" executable="${git.exe}" failonerror="true">
        <arg value="checkout-index"/>
        <arg value="-a"/>
        <arg value="-f"/>
        <arg value="--prefix=${src.export.dir}/"/>
      </exec>
    </sequential>
  </macrodef>

  <macrodef name="make-checksums" description="Macro for building checksum files">
    <attribute name="file"/>
    <sequential>
      <echo>Building checksums for '@{file}'</echo>
      <checksum file="@{file}" algorithm="SHA-512" fileext=".sha512" format="MD5SUM" forceoverwrite="yes" readbuffersize="65536"/>
    </sequential>
  </macrodef>

  <macrodef name="jar-checksum-macro">
      <attribute name="srcdir"/>
      <attribute name="dstdir"/>
    <sequential>
      <delete>
        <fileset dir="@{dstdir}">
          <include name="**/*.jar.sha1"/>
        </fileset>
      </delete>

      <!-- checksum task does not have a flatten=true -->
      <tempfile property="jar-checksum.temp.dir"/>
      <mkdir dir="${jar-checksum.temp.dir}"/>
      <copy todir="${jar-checksum.temp.dir}" flatten="true">
        <fileset dir="@{srcdir}">
          <include name="**/*.jar"/>
          <!-- todo make this something passed into the macro and not some hardcoded set -->
          <exclude name="build/**"/>
          <exclude name="dist/**"/>
          <exclude name="package/**"/>
          <exclude name="example/exampledocs/**"/>
        </fileset>
      </copy>

      <checksum algorithm="SHA1" fileext=".sha1" todir="@{dstdir}">
        <fileset dir="${jar-checksum.temp.dir}"/>
      </checksum>

      <delete dir="${jar-checksum.temp.dir}"/>

      <fixcrlf 
        srcdir="@{dstdir}"
        includes="**/*.jar.sha1"
        eol="lf" fixlast="true" encoding="US-ASCII" />
    </sequential>
  </macrodef>

  <macrodef name="sign-artifacts-macro">
    <attribute name="artifacts.dir"/>
    <sequential>
      <delete failonerror="false">
        <fileset dir="@{artifacts.dir}">
          <include name="**/*.asc"/>
        </fileset>
      </delete>

      <available property="gpg.input.handler" classname="org.apache.tools.ant.input.SecureInputHandler"
                 value="org.apache.tools.ant.input.SecureInputHandler"/>
      <!--else:--><property name="gpg.input.handler" value="org.apache.tools.ant.input.DefaultInputHandler"/>
      <echo>WARNING: ON SOME PLATFORMS YOUR PASSPHRASE WILL BE ECHOED BACK!!!!!</echo>
      <input message="Enter GPG keystore password: >" addproperty="gpg.passphrase">
        <handler classname="${gpg.input.handler}" />
      </input>

      <apply executable="${gpg.exe}" inputstring="${gpg.passphrase}"
             dest="@{artifacts.dir}" type="file" maxparallel="1" verbose="yes">
        <arg value="--passphrase-fd"/>
        <arg value="0"/>
        <arg value="--batch"/>
        <arg value="--armor"/>
        <arg value="--default-key"/>
        <arg value="${gpg.key}"/>
        <arg value="--output"/>
        <targetfile/>
        <arg value="--detach-sig"/>
        <srcfile/>

        <fileset dir="@{artifacts.dir}">
          <include name="**/*.jar"/>
          <include name="**/*.war"/>
          <include name="**/*.zip"/>
          <include name="**/*.tgz"/>
          <include name="**/*.pom"/>
        </fileset>
        <globmapper from="*" to="*.asc"/>
      </apply>
    </sequential>
  </macrodef>

  <!-- JFlex task -->
  <target name="-install-jflex" unless="jflex.loaded" depends="ivy-availability-check,ivy-configure">
    <ivy:cachepath organisation="de.jflex" module="jflex" revision="1.7.0"
                   inline="true" conf="default" transitive="true" pathid="jflex.classpath"/>
    <taskdef name="jflex" classname="jflex.anttask.JFlexTask" classpathref="jflex.classpath"/>
    <property name="jflex.loaded" value="true"/>
  </target>

  <!-- GROOVY scripting engine for ANT tasks -->
  <target name="resolve-groovy" unless="groovy.loaded" depends="ivy-availability-check,ivy-configure">
    <ivy:cachepath organisation="org.codehaus.groovy" module="groovy-all" revision="2.4.17"
      inline="true" conf="default" type="jar" transitive="true" pathid="groovy.classpath"/>
    <taskdef name="groovy"
      classname="org.codehaus.groovy.ant.Groovy"
      classpathref="groovy.classpath"/>
    <property name="groovy.loaded" value="true"/>
  </target>
  
  <!-- Forbidden API Task -->
  <property name="forbidden-base-excludes" value=""/>
  <property name="forbidden-tests-excludes" value=""/>
  <property name="forbidden-sysout-excludes" value=""/>
  
  <target name="-install-forbidden-apis" unless="forbidden-apis.loaded" depends="ivy-availability-check,ivy-configure">
    <ivy:cachepath organisation="de.thetaphi" module="forbiddenapis" revision="3.1"
      inline="true" conf="default" transitive="true" pathid="forbidden-apis.classpath"/>
    <taskdef name="forbidden-apis" classname="de.thetaphi.forbiddenapis.ant.AntTask" classpathref="forbidden-apis.classpath"/>
    <property name="forbidden-apis.loaded" value="true"/>
  </target>  

  <target name="-init-forbidden-apis" depends="-install-forbidden-apis">
    <path id="forbidden-apis.allclasses.classpath">
      <path refid="classpath"/>
      <path refid="test.classpath"/>
      <path refid="junit-path"/>
      <!-- include the output directories, too (so we can still resolve excluded classes: -->
      <pathelement path="${build.dir}/classes/java"/>
      <pathelement path="${build.dir}/classes/test"/>
    </path>
  </target>  

  <condition property="forbidden-isLucene">
    <not>
      <or>
        <matches pattern="^(solr)\b" string="${name}"/>
        <matches pattern="tools" string="${name}"/>
      </or>
    </not>
  </condition>

  <target name="check-forbidden-apis" depends="-check-forbidden-all,-check-forbidden-core,-check-forbidden-tests" description="Check forbidden API calls in compiled class files"/>
  
  <!-- applies to both source and test code -->
  <target name="-check-forbidden-all" depends="-init-forbidden-apis,compile-core,compile-test">
    <forbidden-apis suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath" targetVersion="${javac.release}">
      <signatures>
        <bundled name="jdk-unsafe"/>
        <bundled name="jdk-deprecated"/>
        <bundled name="jdk-non-portable"/>
        <bundled name="jdk-reflection"/>
        <fileset dir="${common.dir}/tools/forbiddenApis">
          <include name="base.txt"/>
          <include name="lucene.txt" if="forbidden-isLucene"/>
        </fileset>
      </signatures>
      <fileset dir="${build.dir}/classes/java" excludes="${forbidden-base-excludes}"/>
      <fileset dir="${build.dir}/classes/test" excludes="${forbidden-tests-excludes}" erroronmissingdir="false"/>
    </forbidden-apis>
  </target>

  <!-- applies to only test code -->
  <target name="-check-forbidden-tests" depends="-init-forbidden-apis,compile-test">
    <forbidden-apis signaturesFile="${common.dir}/tools/forbiddenApis/tests.txt" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath" targetVersion="${javac.release}"> 
      <fileset dir="${build.dir}/classes/test" excludes="${forbidden-tests-excludes}"/>
    </forbidden-apis>
  </target>
 
  <!-- applies to only source code -->
  <target name="-check-forbidden-core" depends="-init-forbidden-apis,compile-core,-check-forbidden-sysout" />

  <target name="-check-forbidden-sysout" depends="-init-forbidden-apis,compile-core">
    <forbidden-apis bundledSignatures="jdk-system-out" suppressAnnotation="**.SuppressForbidden" classpathref="forbidden-apis.allclasses.classpath" targetVersion="${javac.release}">
      <fileset dir="${build.dir}/classes/java" excludes="${forbidden-sysout-excludes}"/>
    </forbidden-apis>
  </target>

  <target name="resolve-markdown" unless="markdown.loaded" depends="resolve-groovy">
    <property name="flexmark.version" value="0.42.6"/>
    <ivy:cachepath transitive="true" resolveId="flexmark" pathid="markdown.classpath">
      <ivy:dependency org="com.vladsch.flexmark" name="flexmark" rev="${flexmark.version}" conf="default" />
      <ivy:dependency org="com.vladsch.flexmark" name="flexmark-ext-autolink" rev="${flexmark.version}" conf="default" />
      <ivy:dependency org="com.vladsch.flexmark" name="flexmark-ext-abbreviation" rev="${flexmark.version}" conf="default" />
    </ivy:cachepath>
    <groovy classpathref="markdown.classpath" src="${common.dir}/tools/src/groovy/install-markdown-filter.groovy"/>
    <property name="markdown.loaded" value="true"/>
  </target>
  
  <!-- markdown macro: Before using depend on the target "resolve-markdown" -->
  
  <macrodef name="markdown">
    <attribute name="todir"/>
    <attribute name="flatten" default="false"/>
    <attribute name="overwrite" default="false"/>
    <element name="nested" optional="false" implicit="true"/>
    <sequential>
      <copy todir="@{todir}" flatten="@{flatten}" overwrite="@{overwrite}" verbose="true"
        preservelastmodified="false" encoding="UTF-8" taskname="markdown"
      >
        <filterchain>
          <tokenfilter>
            <filetokenizer/>
            <replaceregex pattern="\b(LUCENE|SOLR)\-\d+\b" replace="[\0](https://issues.apache.org/jira/browse/\0)" flags="gs"/>
            <markdownfilter/>
          </tokenfilter>
        </filterchain>
        <nested/>
      </copy>
    </sequential>
  </macrodef>

  <target name="regenerate"/>
  
  <macrodef name="check-broken-links">
       <attribute name="dir"/>
     <sequential>
       <exec dir="." executable="${python3.exe}" failonerror="true">
         <!-- Tell Python not to write any bytecode cache into the filesystem: -->
         <arg value="-B"/>
         <arg value="${dev-tools.dir}/scripts/checkJavadocLinks.py"/>
         <arg value="@{dir}"/>
       </exec>
     </sequential>
  </macrodef>

  <macrodef name="check-missing-javadocs">
       <attribute name="dir"/>
       <attribute name="level" default="class"/>
     <sequential>
       <exec dir="." executable="${python3.exe}" failonerror="true">
         <!-- Tell Python not to write any bytecode cache into the filesystem: -->
         <arg value="-B"/>
         <arg value="${dev-tools.dir}/scripts/checkJavaDocs.py"/>
         <arg value="@{dir}"/>
         <arg value="@{level}"/>
       </exec>
     </sequential>
  </macrodef>

  <!--
   compile changes.txt into an html file
   -->
  <macrodef name="build-changes">
    <attribute name="changes.product"/>
    <attribute name="doap.property.prefix" default="doap.@{changes.product}"/>
    <attribute name="changes.src.file" default="CHANGES.txt"/>
    <attribute name="changes.src.doap" default="${dev-tools.dir}/doap/@{changes.product}.rdf"/>
    <attribute name="changes.version.dates" default="build/@{doap.property.prefix}.version.dates.csv"/>
    <attribute name="changes.target.dir" default="${changes.target.dir}"/>
    <attribute name="lucene.javadoc.url" default="${lucene.javadoc.url}"/>
    <sequential>
      <mkdir dir="@{changes.target.dir}"/>
      <xmlproperty keeproot="false" file="@{changes.src.doap}" collapseAttributes="false" prefix="@{doap.property.prefix}"/>
      <echo file="@{changes.version.dates}" append="false">${@{doap.property.prefix}.Project.release.Version.revision}&#xA;</echo>
      <echo file="@{changes.version.dates}" append="true">${@{doap.property.prefix}.Project.release.Version.created}&#xA;</echo>
      <exec executable="${perl.exe}" input="@{changes.src.file}" output="@{changes.target.dir}/Changes.html"
            failonerror="true" logError="true">
        <arg value="-CSD"/>
        <arg value="${changes.src.dir}/changes2html.pl"/>
        <arg value="@{changes.product}"/>
        <arg value="@{changes.version.dates}"/>
        <arg value="@{lucene.javadoc.url}"/>
      </exec>
      <delete file="@{changes.version.dates}"/>
      <copy todir="@{changes.target.dir}">
        <fileset dir="${changes.src.dir}" includes="*.css"/>
      </copy>
    </sequential>
  </macrodef>

  <macrodef name="pitest-macro" description="Executes junit tests.">
    <attribute name="pitest.report.dir" default="${pitest.report.dir}"/>
    <attribute name="pitest.framework.classpath" default="pitest.framework.classpath"/>
    <attribute name="pitest.distance" default="${pitest.distance}" />
    <attribute name="pitest.sysprops" default="${pitest.sysprops}" />
    <attribute name="pitest.threads" default="${pitest.threads}" />
    <attribute name="pitest.testCases" default="${pitest.testCases}" />
    <attribute name="pitest.maxMutations" default="${pitest.maxMutations}" />
    <attribute name="pitest.timeoutFactor" default="${pitest.timeoutFactor}" />
    <attribute name="pitest.timeoutConst" default="${pitest.timeoutConst}" />
    <attribute name="pitest.targetClasses" default="${pitest.targetClasses}" />

    <attribute name="junit.classpath" default="junit.classpath"/>

    <attribute name="src.dir" default="${src.dir}"/>
    <attribute name="build.dir" default="${build.dir}"/>

    <sequential>

        <echo>
PiTest mutation coverage can take a *long* time on even large hardware.
(EC2 32core sandy bridge takes at least 12 hours to run PiTest for the lucene test cases)

The following arguments can be provided to ant to alter its behaviour and target specific tests::

-Dpitest.report.dir (@{pitest.report.dir}) - Change where PiTest writes output reports

-Dpitest.distance (@{pitest.distance}) - How far away from the test class should be mutated
   0 being immeditate callees only

-Dpitest.threads (@{pitest.threads}) - How many threads to use in PiTest 
   (note this is independent of junit threads)

-Dpitest.testCases (@{pitest.testCases}) - Glob of testcases to run

-Dpitest.maxMutations (@{pitest.maxMutations}) - Maximum number of mutations per class under test
    0 being unlimited

-Dpitest.timeoutFactor (@{pitest.timeoutFactor}) - Tunable factor used to determine
    if a test is potentially been mutated to be an infinate loop or O(n!) (or similar)

-Dpitest.timeoutConst (@{pitest.timeoutConst}) - Base constant used for working out timeouts

-Dpitest.targetClasses (@{pitest.targetClasses}) - Classes to consider for mutation
        </echo>

        <taskdef name="pitest" classname="org.pitest.ant.PitestTask"
            classpathref="pitest.framework.classpath" />

        <path id="pitest.classpath">
            <path refid="junit.classpath"/>
            <path refid="pitest.framework.classpath"/>
        </path>

        <junit4:pickseed property="pitest.seed" />

        <property name="pitest.sysprops" value="-Dversion=${version},-Dtest.seed=${pitest.seed},-Djava.security.manager=org.apache.lucene.util.TestSecurityManager,-Djava.security.policy=${tests.policy},-Djava.io.tmpdir=${tests.workDir},-Djunit4.childvm.cwd=${tests.workDir}" />

        <pitest
            classPath="pitest.classpath"
            targetClasses="@{pitest.targetClasses}"
            targetTests="@{pitest.testCases}"
            reportDir="@{pitest.report.dir}"
            sourceDir="@{src.dir}"
            threads="@{pitest.threads}"
            maxMutationsPerClass="@{pitest.maxMutations}"
            timeoutFactor="@{pitest.timeoutFactor}"
            timeoutConst="@{pitest.timeoutConst}"
            verbose="false"
            dependencyDistance="@{pitest.distance}"
            mutableCodePaths="@{build.dir}/classes/java"
            jvmArgs="-ea,@{pitest.sysprops}" />
    </sequential>
  </macrodef>

  <macrodef name="run-jflex">
    <attribute name="dir"/>
    <attribute name="name"/>
    <sequential>
      <!-- The default skeleton is specified here to work around a JFlex ant task bug:    -->
      <!-- invocations with a non-default skeleton will cause following invocations to    -->
      <!-- use the same skeleton, though not specified, unless the default is configured. -->
      <jflex file="@{dir}/@{name}.jflex" outdir="@{dir}" nobak="on"
             skeleton="${common.dir}/core/src/data/jflex/skeleton.default"/>
    </sequential>
  </macrodef>

  <macrodef name="run-jflex-and-disable-buffer-expansion">
    <attribute name="dir"/>
    <attribute name="name"/>
    <sequential>
      <!-- LUCENE-5897: Disallow scanner buffer expansion -->
      <jflex file="@{dir}/@{name}.jflex" outdir="@{dir}" nobak="on"
             skeleton="${common.dir}/core/src/data/jflex/skeleton.disable.buffer.expansion.txt"/>
      <!-- Since the ZZ_BUFFERSIZE declaration is generated rather than in the skeleton, we have to transform it here. -->
      <replaceregexp file="@{dir}/@{name}.java"
                     match="private static final int ZZ_BUFFERSIZE ="
                     replace="private int ZZ_BUFFERSIZE ="/>
    </sequential>
  </macrodef>


</project>