aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/maven.scm
blob: 561ff2ee5bfbd3765ef3f9ae489d6e2c5e12c921 (plain)
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
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2019 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2019 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages maven)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix utils)
  #:use-module (guix build-system ant)
  #:use-module (gnu packages)
  #:use-module (gnu packages base)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages java)
  #:use-module (gnu packages maven-parent-pom)
  #:use-module (gnu packages web)
  #:use-module (gnu packages xml)
  #:use-module (ice-9 match))

(define-public maven-resolver-api
  (package
    (name "maven-resolver-api")
    (version "1.3.1")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/apache/maven-resolver")
                    (commit (string-append "maven-resolver-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1x1gll8nkfl6zgnab78fxxvvhg42b2grxgdh1wp2h4qxsjkxg93d"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-resolver-api.jar"
       #:source-dir "maven-resolver-api/src/main/java"
       #:test-dir "maven-resolver-api/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "maven-resolver-api/pom.xml")))))
    (native-inputs
     `(("java-asm" ,java-asm)
       ("java-cglib" ,java-cglib)
       ("java-hamcrest-core" ,java-hamcrest-core)
       ("java-junit" ,java-junit)
       ("java-mockito-1" ,java-mockito-1)
       ("java-objenesis" ,java-objenesis)))
    (propagated-inputs
     `(("maven-resolver-parent-pom" ,maven-resolver-parent-pom)))
    (home-page "https://github.com/apache/maven-resolver")
    (synopsis "Maven repository system API")
    (description "This package contains the API for the maven repository system.")
    (license license:asl2.0)))

(define maven-resolver-parent-pom
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-parent-pom")
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (add-before 'install 'fix-pom
           (lambda _
             (substitute* "pom.xml"
               (("<classifier>no_aop</classifier>") ""))
             #t))
         (replace 'install
           (install-pom-file "pom.xml")))))
    (propagated-inputs '())))

(define-public maven-resolver-spi
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-spi")
    (arguments
     `(#:jar-name "maven-resolver-spi.jar"
       #:source-dir "maven-resolver-spi/src/main/java"
       #:test-dir "maven-resolver-spi/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "maven-resolver-spi/pom.xml")))))
    (propagated-inputs
     `(("maven-resolver-api" ,maven-resolver-api)))
    (synopsis "Maven repository system SPI")
    (description "This package contains the service provider interface (SPI)
for repository system implementations and repository connectors.")))

(define-public maven-resolver-test-util
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-test-util")
    (arguments
     `(#:jar-name "maven-resolver-test-util.jar"
       #:source-dir "maven-resolver-test-util/src/main/java"
       #:test-dir "maven-resolver-test-util/src/test"
       #:jdk ,icedtea-8))
    (inputs
     `(("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-spi" ,maven-resolver-spi)))
    (synopsis "Utility classes for testing the maven repository system")
    (description "This package contains a collection of utility classes to
ease testing of the repository system.")))

(define-public maven-resolver-util
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-util")
    (arguments
     `(#:jar-name "maven-resolver-util.jar"
       #:source-dir "maven-resolver-util/src/main/java"
       #:test-dir "maven-resolver-util/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "maven-resolver-util/pom.xml")))))
    (propagated-inputs
     `(("maven-resolver-api" ,maven-resolver-api)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-hamcrest-core" ,java-hamcrest-core)
       ("maven-resolver-test-util" ,maven-resolver-test-util)))
    (synopsis "Utility classes for the maven repository system")
    (description "This package contains a collection of utility classes to
ease usage of the repository system.")))

(define-public maven-resolver-connector-basic
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-connector-basic")
    (arguments
     `(#:jar-name "maven-resolver-connector-basic.jar"
       #:source-dir "maven-resolver-connector-basic/src/main/java"
       #:test-dir "maven-resolver-connector-basic/src/test"
       #:jdk ,icedtea-8
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-sisu
           (lambda _
             (mkdir-p "build/classes/META-INF/sisu")
             (with-output-to-file "build/classes/META-INF/sisu/javax.inject.Named"
               (lambda _
                 (display "org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory\n")))
             #t))
         (replace 'install
           (install-from-pom "maven-resolver-connector-basic/pom.xml")))))
    (propagated-inputs
     `(("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-spi" ,maven-resolver-spi)
       ("maven-resolver-util" ,maven-resolver-util)
       ("java-slf4j-api" ,java-slf4j-api)))
    (native-inputs
     `(("java-javax-inject" ,java-javax-inject)
       ("java-junit" ,java-junit)
       ("maven-resolver-test-util" ,maven-resolver-test-util)))
    (synopsis "Maven repository connector implementation")
    (description "This package contains a repository connector implementation
for repositories using URI-based layouts.")))

(define-public maven-resolver-impl
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-impl")
    (arguments
     `(#:jar-name "maven-resolver-impl.jar"
       #:source-dir "maven-resolver-impl/src/main/java"
       #:test-dir "maven-resolver-impl/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-sisu
           (lambda _
             (mkdir-p "build/classes/META-INF/sisu")
             (with-output-to-file "build/classes/META-INF/sisu/javax.inject.Named"
               (lambda _
                 (display
                   (string-append
                     ;; Build this list by looking for files containing "@Named"
                     "org.eclipse.aether.internal.impl.DefaultArtifactResolver\n"
                     "org.eclipse.aether.internal.impl.collect.DefaultDependencyCollector\n"
                     "org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider\n"
                     "org.eclipse.aether.internal.impl.DefaultDeployer\n"
                     "org.eclipse.aether.internal.impl.DefaultFileProcessor\n"
                     "org.eclipse.aether.internal.impl.DefaultInstaller\n"
                     "org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider\n"
                     "org.eclipse.aether.internal.impl.DefaultMetadataResolver\n"
                     "org.eclipse.aether.internal.impl.DefaultOfflineController\n"
                     "org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager\n"
                     "org.eclipse.aether.internal.impl.DefaultRepositoryConnectorProvider\n"
                     "org.eclipse.aether.internal.impl.DefaultRepositoryEventDispatcher\n"
                     "org.eclipse.aether.internal.impl.DefaultRepositoryLayoutProvider\n"
                     "org.eclipse.aether.internal.impl.DefaultRepositorySystem\n"
                     "org.eclipse.aether.internal.impl.DefaultSyncContextFactory\n"
                     "org.eclipse.aether.internal.impl.DefaultTransporterProvider\n"
                     "org.eclipse.aether.internal.impl.DefaultUpdateCheckManager\n"
                     "org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer\n"
                     "org.eclipse.aether.internal.impl.EnhancedLocalRepositoryManagerFactory\n"
                     "org.eclipse.aether.internal.impl.LoggerFactoryProvider\n"
                     "org.eclipse.aether.internal.impl.Maven2RepositoryLayoutFactory\n"
                     "org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory\n"
                     "org.eclipse.aether.internal.impl.slf4j.Slf4jLoggerFactory"))))
             #t))
         (replace 'install
           (install-from-pom "maven-resolver-impl/pom.xml")))))
    (propagated-inputs
     `(("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-spi" ,maven-resolver-spi)
       ("maven-resolver-util" ,maven-resolver-util)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-javax-inject" ,java-javax-inject)
       ("java-guice" ,java-guice)
       ("java-slf4j-api" ,java-slf4j-api)
       ("maven-resolver-parent-pom" ,maven-resolver-parent-pom)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("maven-resolver-test-util" ,maven-resolver-test-util)))))

(define-public maven-resolver-transport-wagon
  (package
    (inherit maven-resolver-api)
    (name "maven-resolver-transport-wagon")
    (arguments
     `(#:jar-name "maven-resolver-transport-wagon.jar"
       #:source-dir "maven-resolver-transport-wagon/src/main/java"
       #:test-dir "maven-resolver-transport-wagon/src/test"
       #:jdk ,icedtea-8
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-sisu
           (lambda _
             (mkdir-p "build/classes/META-INF/sisu")
             (with-output-to-file "build/classes/META-INF/sisu/javax.inject.Named"
               (lambda _
                 (display "org.eclipse.aether.transport.wagon.WagonTransporterFactory\n")))
             #t))
         (add-before 'build 'generate-components.xml
           (lambda _
             (mkdir-p "build/classes/META-INF/plexus")
             (with-output-to-file "build/classes/META-INF/plexus/components.xml"
               (lambda _
                 (display
                   (string-append
                     "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<component-set>
  <components>
    <component>
      <role>org.eclipse.aether.transport.wagon.WagonConfigurator</role>
      <role-hint>plexus</role-hint>
      <implementation>org.eclipse.aether.internal.transport.wagon.PlexusWagonConfigurator</implementation>
      <description />
      <isolated-realm>false</isolated-realm>
      <requirements>
        <requirement>
          <role>org.codehaus.plexus.PlexusContainer</role>
          <role-hint />
          <field-name>container</field-name>
        </requirement>
      </requirements>
    </component>
    <component>
      <role>org.eclipse.aether.transport.wagon.WagonProvider</role>
      <role-hint>plexus</role-hint>
      <implementation>org.eclipse.aether.internal.transport.wagon.PlexusWagonProvider</implementation>
      <description />
      <isolated-realm>false</isolated-realm>
      <requirements>
        <requirement>
          <role>org.codehaus.plexus.PlexusContainer</role>
          <role-hint />
          <field-name>container</field-name>
        </requirement>
      </requirements>
    </component>
  </components>
</component-set>\n"))))
             #t)))))
    (inputs
     `(("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-spi" ,maven-resolver-spi)
       ("maven-resolver-util" ,maven-resolver-util)
       ("java-javax-inject" ,java-javax-inject)
       ("mavne-wagon-provider-api" ,maven-wagon-provider-api)
       ("java-plexus-component-annotation" ,java-plexus-component-annotations)
       ("java-plexus-classworld" ,java-plexus-classworlds)
       ("java-plexus-plexus-util" ,java-plexus-utils)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-hamcrest-core" ,java-hamcrest-core)
       ("maven-resolver-test-util" ,maven-resolver-test-util)
       ("java-guava" ,java-guava)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-aopalliance" ,java-aopalliance)
       ("java-guice" ,java-guice)))
    (synopsis "Transport implementation for Maven")
    (description "This package contains a transport implementation based on
Maven Wagon, for use in Maven.")))

;; aether is the parent project that was forked into maven-resolver.  It used
;; to be used with older versions of Maven, and is still required for some
;; plugins and their dependencies.  This version is required for the plugins,
;; even though there are newer versions of this project.
(define-public java-sonatype-aether-api
  (package
    (name "java-sonatype-aether-api")
    (version "1.7")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/sonatype/sonatype-aether")
                     (commit (string-append "aether-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1wn9fv91n40bvlwbzy0dmh0xqibxl2mpzpnbibhqss3c0zlr1ccq"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "aether-api.jar"
       #:source-dir "aether-api/src/main/java"
       #:test-dir "aether-api/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'install 'install-parent (install-pom-file "pom.xml"))
         (replace 'install (install-from-pom "aether-api/pom.xml")))))
    (propagated-inputs
     `(("java-sonatype-forge-parent-pom" ,java-sonatype-forge-parent-pom-6)))
    (native-inputs `(("java-junit" ,java-junit)))
    (home-page "https://github.com/sonatype/sonatype-aether")
    (synopsis "Maven repository system API")
    (description "This package contains the API for the maven repository system.")
    (license license:asl2.0)))

(define-public java-sonatype-aether-spi
  (package
    (inherit java-sonatype-aether-api)
    (name "java-sonatype-aether-spi")
    (arguments
     `(#:jar-name "aether-spi.jar"
       #:source-dir "aether-spi/src/main/java"
       #:tests? #f; no tests
       #:phases
       (modify-phases %standard-phases
         (replace 'install (install-from-pom "aether-spi/pom.xml")))))
    (propagated-inputs
     `(("java-sonatype-aether-api" ,java-sonatype-aether-api)))
    (synopsis "Maven repository system SPI")
    (description "This package contains the service provider interface (SPI)
for repository system implementations and repository connectors.")))

(define-public java-sonatype-aether-test-util
  (package
    (inherit java-sonatype-aether-api)
    (name "java-sonatype-aether-test-util")
    (arguments
     `(#:jar-name "java-sonatype-aether-test-util.jar"
       #:source-dir "aether-test-util/src/main/java"
       #:test-dir "aether-test-util/src/test"))
    (inputs
     `(("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-sonatype-aether-spi" ,java-sonatype-aether-spi)))
    (synopsis "Utility classes for testing the maven repository system")
    (description "This package contains a collection of utility classes to
ease testing of the repository system.")))

(define-public java-sonatype-aether-util
  (package
    (inherit java-sonatype-aether-api)
    (name "java-sonatype-aether-util")
    (arguments
     `(#:jar-name "aether-util.jar"
       #:source-dir "aether-util/src/main/java"
       #:test-dir "aether-util/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install (install-from-pom "aether-util/pom.xml")))))
    (propagated-inputs
     `(("java-sonatype-aether-api" ,java-sonatype-aether-api)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-sonatype-aether-test-util" ,java-sonatype-aether-test-util)))
    (synopsis "Utility classes for the maven repository system")
    (description "This package contains a collection of utility classes to
ease usage of the repository system.")))

(define-public java-sonatype-aether-impl
  (package
    (inherit java-sonatype-aether-api)
    (name "java-sonatype-aether-impl")
    (arguments
     `(#:jar-name "aether-impl.jar"
       #:source-dir "aether-impl/src/main/java"
       #:test-dir "aether-impl/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'install 'fix-pom
           (lambda _
             (substitute* "aether-impl/pom.xml"
               (("org.sonatype.sisu") "org.codehaus.plexus")
               (("sisu-inject-plexus") "plexus-container-default"))
             #t))
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t))
         (replace 'install (install-from-pom "aether-impl/pom.xml")))))
    (propagated-inputs
     `(("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-sonatype-aether-spi" ,java-sonatype-aether-spi)
       ("java-sonatype-aether-util" ,java-sonatype-aether-util)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("java-slf4j-api" ,java-slf4j-api)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-sonatype-aether-test-util" ,java-sonatype-aether-test-util)))))

;; Again, this old version is required by some maven plugins
(define-public java-eclipse-aether-api
  (package
    (name "java-eclipse-aether-api")
    (version "1.0.2")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/eclipse/aether-core")
                     (commit "aether-1.0.2.v20150114")))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "14d336nn0kh5ddf23j37va3hd8gaai19llrpxhf4bcc7g7sgdqxs"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "aether-api.jar"
       #:source-dir "aether-api/src/main/java"
       #:test-dir "aether-api/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'install 'install-parent (install-pom-file "pom.xml"))
         (replace 'install (install-from-pom "aether-api/pom.xml")))))
    (native-inputs `(("java-junit" ,java-junit)))
    (home-page "https://github.com/sonatype/sonatype-aether")
    (synopsis "Maven repository system API")
    (description "This package contains the API for the maven repository system.")
    (license license:asl2.0)))

(define-public java-eclipse-aether-spi
  (package
    (inherit java-eclipse-aether-api)
    (name "java-eclipse-aether-spi")
    (arguments
     `(#:jar-name "aether-spi.jar"
       #:source-dir "aether-spi/src/main/java"
       #:test-dir "aether-spi/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install (install-from-pom "aether-spi/pom.xml")))))
    (propagated-inputs
     `(("java-eclipse-aether-api" ,java-eclipse-aether-api)))
    (synopsis "Maven repository system SPI")
    (description "This package contains the service provider interface (SPI)
for repository system implementations and repository connectors.")))

(define-public java-eclipse-aether-test-util
  (package
    (inherit java-eclipse-aether-api)
    (name "java-eclipse-aether-test-util")
    (arguments
     `(#:jar-name "aether-test-util.jar"
       #:source-dir "aether-test-util/src/main/java"
       #:test-dir "aether-test-util/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install (install-from-pom "aether-util/pom.xml")))))
    (propagated-inputs
     `(("java-eclipse-aether-api" ,java-eclipse-aether-api)
       ("java-eclipse-aether-spi" ,java-eclipse-aether-spi)))
    (synopsis "Utility classes for testing the maven repository system")
    (description "This package contains a collection of utility classes to
ease testing of the repository system.")))

(define-public java-eclipse-aether-util
  (package
    (inherit java-eclipse-aether-api)
    (name "java-eclipse-aether-util")
    (arguments
     `(#:jar-name "aether-util.jar"
       #:source-dir "aether-util/src/main/java"
       #:test-dir "aether-util/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install (install-from-pom "aether-util/pom.xml")))))
    (propagated-inputs
     `(("java-eclipse-aether-api" ,java-eclipse-aether-api)))
    (native-inputs
     `(("java-eclipse-aether-test-util" ,java-eclipse-aether-test-util)
       ("java-junit" ,java-junit)))
    (synopsis "Utility classes for the maven repository system")
    (description "This package contains a collection of utility classes to
ease usage of the repository system.")))

(define-public java-eclipse-aether-impl
  (package
    (inherit java-eclipse-aether-api)
    (name "java-eclipse-aether-impl")
    (arguments
     `(#:jar-name "aether-impl.jar"
       #:source-dir "aether-impl/src/main/java"
       #:test-dir "aether-impl/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install (install-from-pom "aether-impl/pom.xml")))))
    (propagated-inputs
     `(("java-eclipse-aether-api" ,java-eclipse-aether-api)
       ("java-eclipse-aether-spi" ,java-eclipse-aether-spi)
       ("java-eclipse-aether-util" ,java-eclipse-aether-util)
       ("java-javax-inject" ,java-javax-inject)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-guice" ,java-guice)
       ("java-slf4j-api" ,java-slf4j-api)))
    (native-inputs
     `(("java-eclipse-aether-test-util" ,java-eclipse-aether-test-util)
       ("java-junit" ,java-junit)))))

(define-public maven-shared-utils
  (package
    (name "maven-shared-utils")
    (version "3.2.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "maven-shared-utils-" version "-source-release.zip"))
              (sha256
               (base32
                "1kzmj68wwdcznb36hm6kfz57wbavw7g1rp236pz10znkjljn6rf6"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-shared-utils.jar"
       #:source-dir "src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'fix-/bin/sh-invocation
           (lambda _
             (substitute* (find-files "src" ".*.java$")
               (("/bin/sh") (which "sh")))
             #t))
         (add-before 'check 'remove-cyclic-dep
           (lambda _
             (delete-file
               "src/test/java/org/apache/maven/shared/utils/introspection/ReflectionValueExtractorTest.java")
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("java-jansi" ,java-jansi)
       ("java-commons-io" ,java-commons-io)
       ("java-jsr305" ,java-jsr305)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("maven-parent-pom-30" ,maven-parent-pom-30)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-junit" ,java-junit)
       ("java-hamcrest-core" ,java-hamcrest-core)
       ("java-commons-lang3" ,java-commons-lang3)))
    (home-page "https://maven.apache.org/shared/maven-shared-utils/")
    (synopsis "Plexus-util replacement for maven")
    (description "This project aims to be a functional replacement for
plexus-utils in Maven.  It is not a 100% API compatible replacement but a
replacement with improvements.")
    (license license:asl2.0)))

(define-public maven-plugin-annotations
  (package
    (name "maven-plugin-annotations")
    (version "3.5")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/"
                                  "plugin-tools/maven-plugin-tools-" version
                                  "-source-release.zip"))
              (sha256 (base32 "1ryqhs62j5pas93brhf5dsnvp99hxbvssf681yj5rk3r9h24hqm2"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-plugin-annotations.jar"
       #:source-dir "maven-plugin-annotations/src/main/java"
       #:tests? #f
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "maven-plugin-annotations/pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-artifact)
       ("maven-plugin-tools-parent-pom" ,maven-plugin-tools-parent-pom)))
    (native-inputs
     `(("unzip" ,unzip)))
    (home-page "https://maven.apache.org/plugin-tools/maven-plugin-annotations/")
    (synopsis "Java 5 annotations to use in Mojos")
    (description "This package contains Java 5 annotations for use in Mojos.")
    (license license:asl2.0)))

(define maven-plugin-tools-parent-pom
  (package
    (inherit maven-plugin-annotations)
    (name "maven-plugin-tools-parent-pom")
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (replace 'install
           (install-pom-file "pom.xml")))))
    (propagated-inputs '())))

(define-public maven-wagon-provider-api
  (package
    (name "maven-wagon-provider-api")
    (version "3.3.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://archive.apache.org/dist/maven/wagon/"
                                  "wagon-" version "-source-release.zip"))
              (sha256
               (base32
                "1iq9bilgfklzbxwwhzi3f19mkbaaf9dh9f83h3yz5gbmvypask9a"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-wagon-provider-api.jar"
       #:source-dir "wagon-provider-api/src/main/java"
       #:test-dir "wagon-provider-api/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "wagon-provider-api/pom.xml")))))
    (propagated-inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("maven-wagon-parent-pom" ,maven-wagon-parent-pom)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-junit" ,java-junit)
       ("java-easymock" ,java-easymock)))
    (home-page "https://maven.apache.org/wagon")
    (synopsis "Transport abstraction for Maven")
    (description "Maven Wagon is a transport abstraction that is used in Maven's
artifact and repository handling code.")
    (license license:asl2.0)))

(define maven-wagon-parent-pom
  (package
    (inherit maven-wagon-provider-api)
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (replace 'install
           (install-pom-file "pom.xml")))))
    (propagated-inputs
     `(("maven-parent-pom-33" ,maven-parent-pom-33)))
    (native-inputs
     `(("unzip" ,unzip)))))

(define-public maven-wagon-provider-test
  (package
    (inherit maven-wagon-provider-api)
    (name "maven-wagon-provider-test")
    (arguments
     `(#:jar-name "maven-wagon-provider-test.jar"
       #:source-dir "wagon-provider-test/src/main/java"
       #:tests? #f; no tests
       #:jdk ,icedtea-8))
    (inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("java-eclipse-jetty-http-9.2" ,java-eclipse-jetty-http-9.2)
       ("java-eclipse-jetty-util-9.2" ,java-eclipse-jetty-util-9.2)
       ("java-eclipse-jetty-security-9.2" ,java-eclipse-jetty-security-9.2)
       ("java-eclipse-jetty-server-9.2" ,java-eclipse-jetty-server-9.2)
       ("java-eclipse-jetty-servlet-9.2" ,java-eclipse-jetty-servlet-9.2)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-javaee-servletapi" ,java-javaee-servletapi)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)))
    (synopsis "Test classes from maven-wagon")
    (description "Maven Wagon is a transport abstraction that is used in Maven's
artifact and repository handling code.  This package contains common test
classes used in multiple maven-wagon components.")))

(define-public maven-wagon-file
  (package
    (inherit maven-wagon-provider-api)
    (name "maven-wagon-file")
    (arguments
     `(#:jar-name "maven-wagon-file.jar"
       #:source-dir "wagon-providers/wagon-file/src/main/java"
       #:test-dir "wagon-providers/wagon-file/src/test"
       #:jdk ,icedtea-8
       #:phases
       (modify-phases %standard-phases
         (add-before 'check 'fix-paths
           (lambda _
             ;; Tests assume they are run by maven, which copies test resources
             ;; to target.  Our ant-build-system does the same, but with the
             ;; build directory.
             (substitute* "wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java"
               (("target") "build"))
             #t))
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "wagon-providers/wagon-file/src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t)))))
    (inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)))
    (native-inputs
     `(("maven-wagon-provider-test" ,maven-wagon-provider-test)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-guava" ,java-guava)
       ("java-guice" ,java-guice)
       ("java-javax-inject" ,java-javax-inject)
       ("java-cglib" ,java-cglib)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-cli" ,java-plexus-cli)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-plugin-annotations" ,maven-plugin-annotations)
       ("maven-core" ,maven-core)
       ("maven-model" ,maven-model)
       ("java-commons-cli" ,java-commons-cli)
       ("java-qdox" ,java-qdox)
       ("java-jdom2" ,java-jdom2)
       ("java-asm" ,java-asm)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ,@(package-native-inputs maven-wagon-provider-api)))
    (synopsis "Wagon provider that gets and puts artifacts using the file system")
    (description "Maven Wagon is a transport abstraction that is used in Maven's
artifact and repository handling code.  It uses providers, that are tools to
manage artifacts and deployment.  This package contains the file provider which
gets and puts artifacts using the file system.")))

(define-public maven-wagon-tck-http
  (package
    (inherit maven-wagon-provider-api)
    (name "maven-wagon-tck-http")
    (arguments
     `(#:jar-name "maven-wagon-tck-http.jar"
       #:source-dir "wagon-tcks/wagon-tck-http/src/main/java"
       #:tests? #f; no tests
       #:jdk ,icedtea-8))
    (inputs
     `(("java-plexus-util" ,java-plexus-utils)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)
       ("java-javaee-servletapi" ,java-javaee-servletapi)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-commons-codec" ,java-commons-codec)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-eclipse-jetty-util-9.2" ,java-eclipse-jetty-util-9.2)
       ("java-eclipse-jetty-webapp-9.2" ,java-eclipse-jetty-webapp-9.2)
       ("java-eclipse-jetty-security-9.2" ,java-eclipse-jetty-security-9.2)
       ("java-eclipse-jetty-server-9.2" ,java-eclipse-jetty-server-9.2)
       ("java-eclipse-jetty-servlet-9.2" ,java-eclipse-jetty-servlet-9.2)))
    (synopsis "Wagon HTTP Test Compatibility Kit")
    (description "Maven Wagon is a transport abstraction that is used in Maven's
artifact and repository handling code.  This package contains the HTTP
Test Compatibility Kit.")))

(define-public maven-wagon-http-shared
  (package
    (inherit maven-wagon-provider-api)
    (name "maven-wagon-http-shared")
    (arguments
     `(#:jar-name "maven-wagon-http-shared.jar"
       #:source-dir "wagon-providers/wagon-http-shared/src/main/java"
       #:test-dir "wagon-providers/wagon-http-shared/src/test"
       #:jdk ,icedtea-8
       #:phases
       (modify-phases %standard-phases
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "wagon-providers/wagon-http-shared/src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t)))))
    (inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("java-httpcomponents-httpclient" ,java-httpcomponents-httpclient)
       ("java-httpcomponents-httpcore" ,java-httpcomponents-httpcore)
       ("java-commons-io" ,java-commons-io)
       ("java-jsoup" ,java-jsoup)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)))
    (native-inputs
     `(("maven-wagon-provider-test" ,maven-wagon-provider-test)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-guava" ,java-guava)
       ("java-guice" ,java-guice)
       ("java-javax-inject" ,java-javax-inject)
       ("java-cglib" ,java-cglib)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-cli" ,java-plexus-cli)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-plugin-annotations" ,maven-plugin-annotations)
       ("maven-core" ,maven-core)
       ("maven-model" ,maven-model)
       ("java-commons-cli" ,java-commons-cli)
       ("java-qdox" ,java-qdox)
       ("java-jdom2" ,java-jdom2)
       ("java-asm" ,java-asm)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ,@(package-native-inputs maven-wagon-provider-api)))
    (synopsis "Shared Library for wagon providers supporting HTTP.")
    (description "Maven Wagon is a transport abstraction that is used in Maven's
artifact and repository handling code.  It uses providers, that are tools to
manage artifacts and deployment.  This package contains a shared library for
wagon providers supporting HTTP.")))

(define-public maven-wagon-http
  (package
    (inherit maven-wagon-provider-api)
    (name "maven-wagon-http")
    (arguments
     `(#:jar-name "maven-wagon-http.jar"
       #:source-dir "wagon-providers/wagon-http/src/main/java"
       #:test-dir "wagon-providers/wagon-http/src/test"
       #:test-exclude (list
                        "**/Abstract*.java"
                        ;; FIXME: javax.net.ssl.SSLHandshakeException:
                        ;; sun.security.validator.ValidatorException:
                        ;; PKIX path building failed:
                        ;; sun.security.provider.certpath.SunCertPathBuilderException:
                        ;; unable to find valid certification path to requested target
                        "**/HttpsWagonPreemptiveTest.java"
                        "**/HttpsWagonTest.java"
                        ;; Injection errors
                        "**/TckTest.java")
       #:jdk ,icedtea-8
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'copy-resources
           (lambda _
             (install-file "wagon-providers/wagon-http/src/main/resources/META-INF/plexus/components.xml"
                           "build/classes/META-INF/plexus")
             #t))
         (add-before 'check 'fix-resource-path
           (lambda _
             (substitute* '("wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java"
                            "wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java")
               (("src/test") "wagon-providers/wagon-http/src/test"))
             #t)))))
    (inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("java-httpcomponents-httpclient" ,java-httpcomponents-httpclient)
       ("java-httpcomponents-httpcore" ,java-httpcomponents-httpcore)
       ("maven-wagon-http-shared" ,maven-wagon-http-shared)
       ("maven-wagon-tck-http" ,maven-wagon-tck-http)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)))
    (native-inputs
     `(("maven-wagon-provider-test" ,maven-wagon-provider-test)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-guava" ,java-guava)
       ("java-guice" ,java-guice)
       ("java-inject" ,java-javax-inject)
       ("java-cglib" ,java-cglib)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-cli" ,java-plexus-cli)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-plugin-annotations" ,maven-plugin-annotations)
       ("maven-core" ,maven-core)
       ("maven-model" ,maven-model)
       ("java-commons-cli" ,java-commons-cli)
       ("java-qdox" ,java-qdox)
       ("java-jdom2" ,java-jdom2)
       ("java-asm" ,java-asm)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ("java-javaee-servletapi" ,java-javaee-servletapi)
       ("java-eclipse-jetty-util-9.2" ,java-eclipse-jetty-util-9.2)
       ("java-eclipse-jetty-io-9.2" ,java-eclipse-jetty-io-9.2)
       ("java-eclipse-jetty-http-9.2" ,java-eclipse-jetty-http-9.2)
       ("java-eclipse-jetty-server-9.2" ,java-eclipse-jetty-server-9.2)
       ("java-eclipse-jetty-servlet-9.2" ,java-eclipse-jetty-servlet-9.2)
       ("java-eclipse-jetty-security-9.2" ,java-eclipse-jetty-security-9.2)
       ("java-hamcrest-core" ,java-hamcrest-core)
       ("java-commons-logging-minimal" ,java-commons-logging-minimal)
       ("java-commons-codec" ,java-commons-codec)
       ("java-commons-io" ,java-commons-io)
       ("java-jsoup" ,java-jsoup)
       ("java-slf4j-simple" ,java-slf4j-simple)
       ,@(package-native-inputs maven-wagon-provider-api)))
    (synopsis "Wagon provider that gets and puts artifacts through HTTP(S)")
    (description "Maven Wagon is a transport abstraction that is used in Maven's
artifact and repository handling code.  It uses providers, that are tools to
manage artifacts and deployment.  This package contains a Wagon provider that
gets and puts artifacts through HTTP(S) using Apache HttpClient-4.x.")))

(define maven-pom
  (package
    (name "maven-pom")
    (version "3.6.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/"
                                  "maven-3/" version "/source/"
                                  "apache-maven-" version "-src.tar.gz"))
              (sha256 (base32 "0grw9zp166ci53rd7qkyy2qmwmik37xhiz1z84jpm0msyvzj2n82"))
              (modules '((guix build utils)))
              (snippet
               '(begin
                  (for-each delete-file (find-files "." "\\.jar$"))
                  #t))
              (patches
                (search-patches "maven-generate-component-xml.patch"
                                "maven-generate-javax-inject-named.patch"))))
    (build-system ant-build-system)
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (add-before 'install 'fix-dependencies
           (lambda _
             (substitute* "pom.xml"
               (("classWorldsVersion>.*")
                (string-append
                  "classWorldsVersion>"
                  ,(package-version java-plexus-classworlds)
                  "</classWorldsVersion>\n"))
               (("commonsCliVersion>.*")
                (string-append
                  "commonsCliVersion>"
                  ,(package-version java-commons-cli)
                  "</commonsCliVersion>\n"))
               (("commonsLangVersion>.*")
                (string-append
                  "commonsLangVersion>"
                  ,(package-version java-commons-lang3)
                  "</commonsLangVersion>\n"))
               (("plexusUtilsVersion>.*")
                (string-append
                  "plexusUtilsVersion>"
                  ,(package-version java-plexus-utils)
                  "</plexusUtilsVersion>\n"))
               (("plexusInterpolationVersion>.*")
                (string-append
                  "plexusInterpolationVersion>"
                  ,(package-version java-plexus-interpolation)
                  "</plexusInterpolationVersion>\n"))
               (("guiceVersion>.*")
                (string-append
                  "guiceVersion>"
                  ,(package-version java-guice)
                  "</guiceVersion>\n"))
               (("sisuInjectVersion>.*")
                (string-append
                  "sisuInjectVersion>"
                  ,(package-version java-eclipse-sisu-inject)
                  "</sisuInjectVersion>\n"))
               (("securityDispatcherVersion>.*")
                (string-append
                  "securityDispatcherVersion>"
                  ,(package-version java-plexus-sec-dispatcher)
                  "</securityDispatcherVersion>\n"))
               (("cipherVersion>.*")
                (string-append
                  "cipherVersion>"
                  ,(package-version java-plexus-cipher)
                  "</cipherVersion>\n"))
               (("slf4jVersion>.*")
                (string-append
                  "slf4jVersion>"
                  ,(package-version java-slf4j-api)
                  "</slf4jVersion>\n"))
               (("<classifier>no_aop</classifier>") ""))
             #t))
         (replace 'install
           (install-pom-file "pom.xml")))))
    (propagated-inputs
     `(("maven-parent-pom-33" ,maven-parent-pom-33)))
    (home-page "https://maven.apache.org/")
    (synopsis "Build system")
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains the Maven pom file, used by all maven components.")
    (license license:asl2.0)))

(define-public maven-artifact
  (package
    (inherit maven-pom)
    (name "maven-artifact")
    (arguments
     `(#:jar-name "maven-artifact.jar"
       #:source-dir "maven-artifact/src/main/java"
       #:test-dir "maven-artifact/src/test"
       #:main-class "org.apache.maven.artifact.versioning.ComparableVersion"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "maven-artifact/pom.xml")))))
    (propagated-inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("java-commons-lang3" ,java-commons-lang3)
       ("maven-pom" ,maven-pom)))
    (native-inputs
     `(("java-junit" ,java-junit)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains the Maven Artifact classes, providing the
@code{Artifact} interface, with its @code{DefaultArtifact} implementation.  The
jar file is executable and provides a little tool to display how Maven parses
and compares versions:")))

(define-public maven-model
  (package
    (inherit maven-artifact)
    (name "maven-model")
    (arguments
     `(#:jar-name "maven-model.jar"
       #:source-dir "maven-model/src/main/java"
       #:test-dir "maven-model/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "maven-model/src/main/java" version
                       "false" "true"))
             (let ((file "maven-model/src/main/mdo/maven.mdo"))
               (modello-single-mode file "4.0.0" "java")
               (modello-single-mode file "4.0.0" "xpp3-reader")
               (modello-single-mode file "4.0.0" "xpp3-writer")
               (modello-single-mode file "4.0.0" "xpp3-extended-reader"))
             #t))
         (replace 'install (install-from-pom "maven-model/pom.xml")))))
    (propagated-inputs
     `(("java-commons-lang3" ,java-commons-lang3)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-pom" ,maven-pom)))
    (native-inputs
     `(("java-modello-core" ,java-modello-core)
       ;; for modello:
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-guice" ,java-guice)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-javax-inject" ,java-javax-inject)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-guava" ,java-guava)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ("java-sisu-build-api" ,java-sisu-build-api)
       ;; modello plugins:
       ("java-modello-plugins-java" ,java-modello-plugins-java)
       ("java-modello-plugins-xml" ,java-modello-plugins-xml)
       ("java-modello-plugins-xpp3" ,java-modello-plugins-xpp3)
       ;; for tests
       ("java-junit" ,java-junit)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains the model for Maven @dfn{POM} (Project Object Model),
so really just plain Java objects.")))

(define-public maven-builder-support
  (package
    (inherit maven-artifact)
    (name "maven-builder-support")
    (arguments
     `(#:jar-name "maven-builder-support.jar"
       #:source-dir "maven-builder-support/src/main/java"
       #:jdk ,icedtea-8
       #:test-dir "maven-builder-support/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'check 'fix-paths
           (lambda _
             (with-directory-excursion "maven-builder-support/src/test/java"
               (substitute*
                 '("org/apache/maven/building/FileSourceTest.java"
                   "org/apache/maven/building/UrlSourceTest.java")
                 (("target/test-classes") "maven-builder-support/src/test/resources")))
             #t))
         (replace 'install (install-from-pom "maven-builder-support/pom.xml")))))
    (propagated-inputs
     `(("maven-pom" ,maven-pom)))
    (native-inputs
     `(("java-junit" ,java-junit)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains a support library for descriptor builders (model,
setting, toolchains)")))

(define-public maven-settings
  (package
    (inherit maven-artifact)
    (name "maven-settings")
    (arguments
     `(#:jar-name "maven-settings.jar"
       #:source-dir "maven-settings/src/main/java"
       #:tests? #f; no tests
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "maven-settings/src/main/java" version
                       "false" "true"))
             (let ((file "maven-settings/src/main/mdo/settings.mdo"))
               (modello-single-mode file "1.1.0" "java")
               (modello-single-mode file "1.1.0" "xpp3-reader")
               (modello-single-mode file "1.1.0" "xpp3-writer"))
             #t))
         (replace 'install (install-from-pom "maven-settings/pom.xml")))))
    (propagated-inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("maven-pom" ,maven-pom)))
    (native-inputs
     `(("java-modello-core" ,java-modello-core)
       ;; for modello:
       ;("container" ,java-plexus-container-default)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-guice" ,java-guice)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-javax-inject" ,java-javax-inject)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-guava" ,java-guava)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ("java-sisu-build-api" ,java-sisu-build-api)
       ;; modello plugins:
       ("java-modello-plugins-java" ,java-modello-plugins-java)
       ("java-modello-plugins-xml" ,java-modello-plugins-xml)
       ("java-modello-plugins-xpp3" ,java-modello-plugins-xpp3)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains strictly the model for Maven settings, that is
simply plain java objects.")))

(define-public maven-settings-builder
  (package
    (inherit maven-artifact)
    (name "maven-settings-builder")
    (arguments
     `(#:jar-name "maven-settings-builder.jar"
       #:source-dir "maven-settings-builder/src/main/java"
       #:jdk ,icedtea-8
       #:test-dir "maven-settings-builder/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-components.xml
           (lambda _
             (mkdir-p "build/classes/META-INF/plexus")
             (chmod "components.sh" #o755)
             (invoke "./components.sh" "maven-settings-builder/src/main/java"
                     "build/classes/META-INF/plexus/components.xml")
             #t))
         (replace 'install (install-from-pom "maven-settings-builder/pom.xml")))))
    (propagated-inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-plexus-sec-dispatcher" ,java-plexus-sec-dispatcher)
       ("maven-builder-support" ,maven-builder-support)
       ("maven-settings" ,maven-settings)
       ("maven-pom" ,maven-pom)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains the effective model builder, with profile activation,
inheritance, interpolation, @dots{}")))

(define-public maven-model-builder
  (package
    (inherit maven-artifact)
    (name "maven-model-builder")
    (arguments
     `(#:jar-name "maven-model-builder.jar"
       #:source-dir "maven-model-builder/src/main/java"
       #:jdk ,icedtea-8
       #:test-dir "maven-model-builder/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'copy-resources
           (lambda _
             (copy-recursively "maven-model-builder/src/main/resources"
                               "build/classes")
             #t))
         (add-before 'build 'generate-components.xml
           (lambda _
             (mkdir-p "build/classes/META-INF/plexus")
             (chmod "components.sh" #o755)
             (invoke "./components.sh" "maven-model-builder/src/main/java"
                     "build/classes/META-INF/plexus/components.xml")
             #t))
         (add-before 'check 'fix-paths
           (lambda _
             (substitute* (find-files "maven-model-builder/src/test/java" ".*.java")
               (("src/test") "maven-model-builder/src/test"))
             #t))
         (replace 'install
           (install-from-pom "maven-model-builder/pom.xml")))))
    (propagated-inputs
     `(("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-artifact" ,maven-artifact)
       ("maven-builder-support" ,maven-builder-support)
       ("maven-model" ,maven-model)
       ("maven-pom" ,maven-pom)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-guava" ,java-guava)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("guice" ,java-guice)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("sisu-inject" ,java-eclipse-sisu-inject)
       ("javax-inject" ,java-javax-inject)
       ("java-xmlunit" ,java-xmlunit)
       ("java-xmlunit-matchers" ,java-xmlunit-matchers)
       ("xbean" ,java-geronimo-xbean-reflect)
       ("classworlds" ,java-plexus-classworlds)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains the effective model builder, with profile activation,
inheritance, interpolation, @dots{}")))

(define-public maven-repository-metadata
  (package
    (inherit maven-artifact)
    (name "maven-repository-metadata")
    (arguments
     `(#:jar-name "maven-repository-metadata.jar"
       #:source-dir "maven-repository-metadata/src/main/java"
       #:jdk ,icedtea-8
       #:tests? #f; no tests
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "maven-repository-metadata/src/main/java" version
                       "false" "true"))
             (let ((file "maven-repository-metadata/src/main/mdo/metadata.mdo"))
               (modello-single-mode file "1.1.0" "java")
               (modello-single-mode file "1.1.0" "xpp3-reader")
               (modello-single-mode file "1.1.0" "xpp3-writer"))
             #t))
         (replace 'install
           (install-from-pom "maven-repository-metadata/pom.xml")))))
    (propagated-inputs
     `(("java-plexus-utils" ,java-plexus-utils)
       ("maven-pom" ,maven-pom)))
    (native-inputs
     `(("modello" ,java-modello-core)
       ;; for modello:
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-guice" ,java-guice)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-javax-inject" ,java-javax-inject)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-guava" ,java-guava)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ("java-sisu-build-api" ,java-sisu-build-api)
       ;; modello plugins:
       ("java-modello-plugins-java" ,java-modello-plugins-java)
       ("java-modello-plugins-xml" ,java-modello-plugins-xml)
       ("java-modello-plugins-xpp3" ,java-modello-plugins-xpp3)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains strictly the model for Maven Repository Metadata,
so really just plain objects.")))

(define-public maven-resolver-provider
  (package
    (inherit maven-artifact)
    (name "maven-resolver-provider")
    (arguments
     `(#:jar-name "maven-resolver-provider.jar"
       #:source-dir "maven-resolver-provider/src/main/java"
       #:test-dir "maven-resolver-provider/src/test"
       #:jdk ,icedtea-8
       #:tests? #f; dependency loop on maven-core (@Component RepositorySystem)
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-sisu-named
           (lambda _
             (mkdir-p "build/classes/META-INF/sisu")
             (chmod "./sisu.sh" #o755)
             (invoke "./sisu.sh" "maven-resolver-provider/src/main/java"
                     "build/classes/META-INF/sisu/javax.inject.Named")
             #t))
         (replace 'install
           (install-from-pom "maven-resolver-provider/pom.xml")))))
    (propagated-inputs
     `(("maven-model" ,maven-model)
       ("maven-model-builder" ,maven-model-builder)
       ("maven-resolver-spi" ,maven-resolver-spi)
       ("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-impl" ,maven-resolver-impl)
       ("maven-resolver-util" ,maven-resolver-util)
       ("maven-builder-support" ,maven-builder-support)
       ("maven-repository-metadata" ,maven-repository-metadata)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-guice" ,java-guice)
       ("java-javax-inject" ,java-javax-inject)))))

(define-public maven-plugin-api
  (package
    (inherit maven-artifact)
    (name "maven-plugin-api")
    (arguments
     `(#:jar-name "maven-plugin-api.jar"
       #:source-dir "maven-plugin-api/src/main/java"
       #:jdk ,icedtea-8
       #:test-dir "maven-plugin-api/src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "maven-plugin-api/src/main/java" version
                       "false" "true"))
             (let ((file "maven-plugin-api/src/main/mdo/lifecycle.mdo"))
               (modello-single-mode file "1.0.0" "java")
               (modello-single-mode file "1.0.0" "xpp3-reader")
               (modello-single-mode file "1.0.0" "xpp3-writer"))
             #t))
         (replace 'install
           (install-from-pom "maven-plugin-api/pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-artifact)
       ("maven-model" ,maven-model)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("guice" ,java-guice)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("sisu-inject" ,java-eclipse-sisu-inject)
       ("javax-inject" ,java-javax-inject)
       ("utils" ,java-plexus-utils)))
    (native-inputs
     `(("modello" ,java-modello-core)
       ;; for modello:
       ("classworlds" ,java-plexus-classworlds)
       ("guava" ,java-guava)
       ("xbean" ,java-geronimo-xbean-reflect)
       ("build-api" ,java-sisu-build-api)
       ;; modello plugins:
       ("java" ,java-modello-plugins-java)
       ("xml" ,java-modello-plugins-xml)
       ("xpp3" ,java-modello-plugins-xpp3)
       ;; for tests
       ("java-junit" ,java-junit)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains strictly the API for plugins -- composed of goals
implemented by Mojos -- development.

A plugin is described in a @file{META-INF/maven/plugin.xml} plugin descriptor,
generally generated from plugin sources using maven-plugin-plugin.")))

(define-public maven-core-bootstrap
  (hidden-package
    (package
      (inherit maven-artifact)
      (name "maven-core")
      (arguments
       `(#:jar-name "maven-core.jar"
         #:source-dir "src/main/java"
         #:jdk ,icedtea-8
         ;; Tests need maven-compat, which requires maven-core
         #:tests? #f
         #:phases
         (modify-phases %standard-phases
           (add-before 'configure 'chdir
             (lambda _
               ;; Required for generating components.xml in maven-core
               (chdir "maven-core")
               #t))
           (add-before 'build 'copy-resources
             (lambda _
               (mkdir-p "build/classes/")
               (copy-recursively "src/main/resources" "build/classes")
               #t))
           (add-after 'copy-resources 'fill-properties
             (lambda _
               ;; This file controls the output of some mvn subcommands, such as
               ;; mvn -version.
               (substitute* "build/classes/org/apache/maven/messages/build.properties"
                 (("\\$\\{buildNumber\\}") "guix_build")
                 (("\\$\\{timestamp\\}") "0")
                 (("\\$\\{project.version\\}") ,(package-version maven-artifact))
                 (("\\$\\{distributionId\\}") "apache-maven")
                 (("\\$\\{distributionShortName\\}") "Maven")
                 (("\\$\\{distributionName\\}") "Apache Maven"))
               #t))
           (add-before 'build 'generate-sisu-named
             (lambda _
               (mkdir-p "build/classes/META-INF/sisu")
               (chmod "../sisu.sh" #o755)
               (invoke "../sisu.sh" "src/main/java"
                       "build/classes/META-INF/sisu/javax.inject.Named")
               #t))
           (add-before 'build 'generate-models
             (lambda* (#:key inputs #:allow-other-keys)
               (define (modello-single-mode file version mode)
                 (invoke "java" "org.codehaus.modello.ModelloCli"
                         file mode "src/main/java" version
                         "false" "true"))
               (let ((file "src/main/mdo/toolchains.mdo"))
                 (modello-single-mode file "1.1.0" "java")
                 (modello-single-mode file "1.1.0" "xpp3-reader")
                 (modello-single-mode file "1.1.0" "xpp3-writer"))
               #t))
           (add-before 'install 'fix-pom
             (lambda _
               (substitute* "pom.xml"
                 (("<classifier>no_aop</classifier>") ""))
               #t))
           (replace 'install
             (install-from-pom "pom.xml")))))
      (propagated-inputs
       `(("maven-artifact" ,maven-artifact)
         ("maven-resolver-provider" ,maven-resolver-provider)
         ("maven-builder-support" ,maven-builder-support)
         ("maven-model" ,maven-model)
         ("maven-model-builder" ,maven-model-builder)
         ("maven-settings" ,maven-settings)
         ("maven-settings-builder" ,maven-settings-builder)
         ("maven-plugin-api" ,maven-plugin-api)
         ("maven-repository-metadata" ,maven-repository-metadata)
         ("maven-shared-utils" ,maven-shared-utils)
         ("java-plexus-component-annotations" ,java-plexus-component-annotations)
         ("java-plexus-utils" ,java-plexus-utils)
         ("java-commons-lang3" ,java-commons-lang3)
         ("java-guava" ,java-guava)
         ("java-guice" ,java-guice)
         ("maven-resolver-api" ,maven-resolver-api)
         ("maven-resolver-spi" ,maven-resolver-spi)
         ("maven-resolver-util" ,maven-resolver-util)
         ("maven-resolver-impl" ,maven-resolver-impl)
         ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
         ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
         ("java-javax-inject" ,java-javax-inject)
         ("java-plexus-classworld" ,java-plexus-classworlds)))
      (native-inputs
       `(("java-modello-core" ,java-modello-core)
         ("java-cglib" ,java-cglib)
         ("java-asm" ,java-asm)
         ("java-plexus-classworlds" ,java-plexus-classworlds)
         ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
         ("java-sisu-build-api" ,java-sisu-build-api)
         ("java-modello-plugins-java" ,java-modello-plugins-java)
         ("java-modello-plugins-xml" ,java-modello-plugins-xml)
         ("java-modello-plugins-xpp3" ,java-modello-plugins-xpp3)
         ;; tests
         ("java-junit" ,java-junit)
         ("java-mockito-1" ,java-mockito-1)
         ("java-commons-jxpath" ,java-commons-jxpath)))
      (description "Apache Maven is a software project management and comprehension
tool.  This package contains the maven core classes managing the whole build
process."))))

(define-public maven-core
  (package
    (inherit maven-core-bootstrap)
    (arguments
      (substitute-keyword-arguments (package-arguments maven-core-bootstrap)
        ((#:phases phases)
         `(modify-phases ,phases
            (add-before 'build 'modify-metainf
              (lambda _
                (substitute* "build.xml"
                  (("message=\"\"") "message=\"Implementation-Version: 3.5.4\n\""))
                #t))
            (add-before 'build 'add-maven-files
              (lambda _
                (mkdir-p "build/classes/META-INF/maven/org.apache.maven/maven-core")
                (copy-file "pom.xml"
                           "build/classes/META-INF/maven/org.apache.maven/maven-core/pom.xml")
                (with-output-to-file "build/classes/META-INF/maven/org.apache.maven/maven-core/pom.properties"
                  (lambda _
                    (format #t "version=~a~%
groupId=org.apache.maven~%
artifactId=maven-core" ,(package-version maven-core-bootstrap))))
                #t))
            (add-after 'build 'generate-metadata
              (lambda _
                (define (components file)
                  (let ((sxml (with-input-from-file file
                                (lambda _ (xml->sxml (current-input-port)
                                                     #:trim-whitespace? #t)))))
                    ;; Select the list of <component>s inside the <component-set>
                    ;; and <components>.
                    ((@ (ice-9 match) match) sxml
                     (('*TOP*
                       ('*PI* foo ...)
                       ('component-set
                        ('components x ...))) x))))
                (use-modules (sxml simple))
                (delete-file "build/classes/META-INF/plexus/components.xml")
                (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                        "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                        "--source" "build/classes/META-INF/plexus"
                        "--output" "build/classes/META-INF/plexus/components.t.xml"
                        "--classes" "build/classes"
                        "--descriptors" "build/classes")
                ;; Now we merge all other components from hand-written xml
                (let ((generated-xml (components "build/classes/META-INF/plexus/components.t.xml"))
                      (components-xml (components "src/main/resources/META-INF/plexus/components.xml"))
                      (default-bindings-xml (components "src/main/resources/META-INF/plexus/default-bindings.xml"))
                      (artifact-handlers-xml (components "src/main/resources/META-INF/plexus/artifact-handlers.xml")))
                  (with-output-to-file "build/classes/META-INF/plexus/components.xml"
                    (lambda _
                      (display "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
                      (sxml->xml
                        `(component-set
                           (components
                             ,@(append generated-xml components-xml
                                       default-bindings-xml
                                       artifact-handlers-xml)))))))
                #t))
            (add-after 'generate-metadata 'rebuild
              (lambda _
                (invoke "ant" "jar")
                #t))))))
    (native-inputs
     `(("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-commons-cli" ,java-commons-cli)
       ("java-plexus-cli" ,java-plexus-cli)
       ("java-jdom2" ,java-jdom2)
       ("java-qdox" ,java-qdox)
       ("maven-core-boot" ,maven-core-bootstrap)
       ,@(package-native-inputs maven-core-bootstrap)))))

(define-public maven-embedder
  (package
    (inherit maven-artifact)
    (name "maven-embedder")
    (arguments
     `(#:jar-name "maven-embedder.jar"
       #:source-dir "maven-embedder/src/main/java"
       #:test-dir "maven-embedder/src/test"
       #:test-exclude (list "**/MavenCliTest.java")
       #:jdk ,icedtea-8
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-sisu-named
           (lambda _
             (mkdir-p "build/classes/META-INF/sisu")
             (chmod "sisu.sh" #o755)
             (invoke "./sisu.sh" "maven-embedder/src/main/java"
                     "build/classes/META-INF/sisu/javax.inject.Named")
             #t))
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "maven-embedder/src/main/java" version
                       "false" "true"))
             (let ((file "maven-embedder/src/main/mdo/core-extensions.mdo"))
               (modello-single-mode file "1.0.0" "java")
               (modello-single-mode file "1.0.0" "xpp3-reader")
               (modello-single-mode file "1.0.0" "xpp3-writer"))
             #t))
         (add-before 'check 'fix-test-paths
           (lambda _
             (substitute* "maven-embedder/src/test/java/org/apache/maven/cli/CLIManagerDocumentationTest.java"
               (("target/test-classes") "build/test-classes"))
             #t))
         (add-before 'check 'fix-test-compilation
           (lambda _
             ;; Tests are in the java/ subdir. Other subdirectories contain
             ;; additional test plugins, with duplicate classes, so we can't
             ;; compile them. Also, they are meant to be built with maven, to
             ;; test its build process.
             (substitute* "build.xml"
               (("srcdir=\"maven-embedder/src/test\"")
                "srcdir=\"maven-embedder/src/test/java\""))
             #t))
         (replace 'install
           (install-from-pom "maven-embedder/pom.xml")))))
    (propagated-inputs
     `(("maven-core" ,maven-core)
       ("maven-artifact" ,maven-artifact)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-builder-support" ,maven-builder-support)
       ("maven-model" ,maven-model)
       ("maven-model-builder" ,maven-model-builder)
       ("maven-settings" ,maven-settings)
       ("maven-settings-builder" ,maven-settings-builder)
       ("maven-shared-utils" ,maven-shared-utils)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-plexus-util" ,java-plexus-utils)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-cipher" ,java-plexus-cipher)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-sec-dispatcher" ,java-plexus-sec-dispatcher)
       ("maven-resolevr-util" ,maven-resolver-util)
       ("maven-resolevr-api" ,maven-resolver-api)
       ("java-logback-core" ,java-logback-core)
       ("java-logback-classic" ,java-logback-classic)
       ("java-commons-cli" ,java-commons-cli)
       ("java-commons-io" ,java-commons-io)
       ("java-commons-lang3" ,java-commons-lang3)
       ("java-guava" ,java-guava)
       ("java-guice" ,java-guice)
       ("java-javax-inject" ,java-javax-inject)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-slf4j-simple" ,java-slf4j-simple)
       ("java-jsr250" ,java-jsr250)))
    (native-inputs
     `(("java-modello-core" ,java-modello-core)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ("java-sisu-build-api" ,java-sisu-build-api)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-modello-plugins-java" ,java-modello-plugins-java)
       ("java-modello-plugins-xml" ,java-modello-plugins-xml)
       ("java-modello-plugins-xpp3" ,java-modello-plugins-xpp3)
       ;; tests
       ("java-junit" ,java-junit)
       ("java-objenesis" ,java-objenesis)
       ("java-mockito-1" ,java-mockito-1)
       ("java-hamcrest-core" ,java-hamcrest-core)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains a Maven embeddable component, with CLI and
logging support.")))

(define-public maven-compat
  (package
    (inherit maven-artifact)
    (name "maven-compat")
    (arguments
     `(#:jar-name "maven-compat.jar"
       #:source-dir "src/main/java"
       #:jdk ,icedtea-8
       #:test-dir "src/test"
       #:phases
       (modify-phases %standard-phases
         ;; Tests assume we're in this directory
         (add-before 'configure 'chdir
           (lambda _
             (chdir "maven-compat")
             #t))
         (add-before 'build 'recreate-removed-jar
           (lambda _
             (with-output-to-file "src/test/repository-system/maven-core-2.1.0.jar"
               (const #t))
             (with-directory-excursion "src/test/resources"
               (with-output-to-file "artifact-install/artifact-1.0.jar"
                 (lambda _
                   (format #t "dummy~%")))
               (for-each
                 (lambda (file)
                   (with-output-to-file file
                     (lambda _
                       (format #t "foo~%"))))
                 '("local-repo/maven-test/jars/maven-test-a-1.0.jar"
                   "local-repo/maven-test/jars/maven-test-c-1.0.jar"
                   "local-repo/maven-test/jars/maven-test-d-1.0.jar"
                   "inheritance-repo/t04/maven-test/jars/t04-a-1.0.jar"
                   "inheritance-repo/t04/maven-test/jars/t04-b-1.0.jar"
                   "inheritance-repo/t04/maven-test/jars/t04-b-2.0.jar"
                   "inheritance-repo/t04/maven-test/jars/t04-c-1.0.jar"
                   "inheritance-repo/t04/maven-test/jars/t04-c-2.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-a-1.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-a-2.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-b-1.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-b-1.1.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-b-2.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-c-1.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-d-1.0.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-d-1.1.jar"
                   "inheritance-repo/t05/maven-test/jars/t05-d-1.2.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-a-1.0.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-b-1.0.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-b-1.1.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-c-1.0.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-d-1.0.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-d-1.1.jar"
                   "inheritance-repo/t06/maven-test/jars/t06-d-1.2.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-a-1.0.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-b-1.0.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-b-1.1.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-c-1.0.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-d-1.0.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-d-1.1.jar"
                   "inheritance-repo/t07/maven-test/jars/t07-d-1.2.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-a-1.0.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-b-1.0.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-b-1.1.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-c-1.0.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-d-1.0.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-d-1.1.jar"
                   "inheritance-repo/t08/maven-test/jars/t08-d-1.2.jar"
                   "inheritance-repo/t09/maven-test/jars/t09-a-1.0.jar"
                   "inheritance-repo/t09/maven-test/jars/t09-b-1.0.jar"
                   "inheritance-repo/t09/maven-test/jars/t09-c-1.0.jar"
                   "inheritance-repo/t09/maven-test/jars/t09-d-1.0.jar"
                   "inheritance-repo/t10/maven-test/jars/t10-a-1.0.jar"
                   "inheritance-repo/t10/maven-test/jars/t10-b-1.0.jar"
                   "inheritance-repo/t10/maven-test/jars/t10-c-1.0.jar"))
               (with-directory-excursion "local-repo/snapshot-test/jars"
                 (for-each
                   (lambda (file)
                     (with-output-to-file file
                       (lambda _
                         ;; No end-of-line
                         (format #t "local"))))
                   '("maven-snapshot-e-1.0-SNAPSHOT.jar"
                     "maven-snapshot-b-1.0-SNAPSHOT.jar"
                     "maven-snapshot-a-1.0-SNAPSHOT.jar"))))
             (for-each
               (lambda (letter)
                 (with-directory-excursion
                   (string-append "src/test/remote-repo/org/apache/maven/its/"
                                  letter "/0.1")
                   (let ((dir (string-append "META-INF/maven/org.apache.maven.its/"
                                             letter)))
                     (mkdir-p dir)
                     (copy-file (string-append letter "-0.1.pom")
                                (string-append dir "/pom.xml"))
                     (with-output-to-file (string-append dir "/pom.properties")
                       (lambda _
                         (format #t "version=0.1~%")
                         (format #t "groupId=org.apache.maven.its")
                         (format #t (string-append "artifactId=" letter))))
                     (with-output-to-file "META-INF/MANIFEST.MF"
                       (lambda _
                         (format #t "Manifest-Version: 1.0~%"))))
                     (invoke "jar" "cmf" "META-INF/MANIFEST.MF"
                             (string-append letter "-0.1.jar") "META-INF")))
               '("a" "b"))
             #t))
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "src/main/java" version
                       "false" "true"))
             (let ((file "src/main/mdo/profiles.mdo"))
               (modello-single-mode file "1.0.0" "java")
               (modello-single-mode file "1.0.0" "xpp3-reader")
               (modello-single-mode file "1.0.0" "xpp3-writer"))
             (let ((file "src/main/mdo/paramdoc.mdo"))
               (modello-single-mode file "1.0.0" "java")
               (modello-single-mode file "1.0.0" "xpp3-reader")
               (modello-single-mode file "1.0.0" "xpp3-writer"))
             #t))
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-before 'check 'build-tests
          (lambda _
            (invoke "ant" "compile-tests")
            #t))
         (add-after 'build-tests 'generate-test-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
                                                 ":build/classes"
                                                 ":build/test-classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/test/java"
                     "--output" "build/test-classes/META-INF/plexus/components.xml"
                     "--classes" "build/test-classes"
                     "--descriptors" "build/test-classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-artifact)
       ("maven-repository-metadata" ,maven-repository-metadata)
       ("maven-builder-support" ,maven-builder-support)
       ("maven-model" ,maven-model)
       ("maven-model-builder" ,maven-model-builder)
       ("maven-settings" ,maven-settings)
       ("maven-settings-builder" ,maven-settings-builder)
       ("maven-core" ,maven-core)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)
       ("maven-wagon-file" ,maven-wagon-file)
       ("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-util" ,maven-resolver-util)
       ("maven-resolver-spi" ,maven-resolver-spi)
       ("java-plexus-interpolation" ,java-plexus-interpolation)))
    (native-inputs
     `(("java-modello-core" ,java-modello-core)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-geronimo-xbean-reflect" ,java-geronimo-xbean-reflect)
       ("java-sisu-build-api" ,java-sisu-build-api)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-exclispe-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-javax-inject" ,java-javax-inject)
       ("java-guice" ,java-guice)
       ("java-guava" ,java-guava)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-modello-plugins-java" ,java-modello-plugins-java)
       ("java-modello-plugins-xml" ,java-modello-plugins-xml)
       ("java-modello-plugins-xpp3" ,java-modello-plugins-xpp3)
       ;; metadata
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-commons-cli" ,java-commons-cli)
       ("java-plexus-cli" ,java-plexus-cli)
       ("java-jdom2" ,java-jdom2)
       ("maven-plugin-api" ,maven-plugin-api)
       ("java-qdox" ,java-qdox)
       ;; tests
       ("java-plexus-cipher" ,java-plexus-cipher)
       ("java-plexus-sec-dispatcher" ,java-plexus-sec-dispatcher)
       ("java-jsr250" ,java-jsr250)
       ("java-cdi-api" ,java-cdi-api)
       ("java-junit" ,java-junit)
       ("maven-resolver-impl" ,maven-resolver-impl)
       ("maven-resolver-connector-basic" ,maven-resolver-connector-basic)
       ("maven-resolver-transport-wagon" ,maven-resolver-transport-wagon)
       ("java-commons-lang3" ,java-commons-lang3)
       ("java-aop" ,java-aopalliance)
       ("maven-resolver-provider" ,maven-resolver-provider)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-slf4j-simple" ,java-slf4j-simple)
       ,@(package-inputs java-slf4j-api)))
    (description "Apache Maven is a software project management and comprehension
tool.  This package contains Maven2 classes maintained as compatibility
layer for plugins that need to keep Maven2 compatibility.")))

(define-public maven
  (package
    (inherit maven-artifact)
    (name "maven")
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (replace 'build
           (lambda* (#:key inputs #:allow-other-keys)
             ;; Recreate the configuration for the loader
             (with-output-to-file "apache-maven/src/bin/m2.conf"
               (lambda _
                 (format #t "main is org.apache.maven.cli.MavenCli from plexus.core~%")
                 (format #t "~%")
                 (format #t "set maven.conf default ${maven.home}/conf~%")
                 (format #t "~%")
                 (format #t "[plexus.core]~%")
                 (format #t "load       ${maven.conf}/logging~%")
                 (format #t "optionally ${maven.home}/lib/ext/*.jar~%")
                 ;; Reference every jar so plexus-classworlds can find them.
                 (for-each
                   (lambda (dependency)
                     (for-each
                       (lambda (file)
                         (format #t "load       ~a~%" file))
                       (find-files (assoc-ref inputs dependency) ".*.jar$")))
                   '("maven-artifact" "maven-embedder" "maven-core" "maven-compat"
                     "maven-builder-support" "maven-model" "maven-model-builder"
                     "maven-settings" "maven-settings-builder" "maven-plugin-api"
                     "maven-repository-metadata" "maven-shared-utils" "maven-resolver-api"
                     "maven-resolver-spi" "maven-resolver-util" "maven-resolver-impl"
                     "maven-resolver-connector-basic" "maven-resolver-provider"
                     "maven-resolver-transport-wagon" "maven-wagon-provider-api"
                     "maven-wagon-file" "maven-wagon-http" "java-commons-logging-minimal"
                     "java-httpcomponents-httpclient" "java-httpcomponents-httpcore"
                     "maven-wagon-http-shared" "maven-wagon-tck-http"
                     "java-eclipse-sisu-plexus" "java-guice" "java-aopalliance"
                     "java-cglib" "java-asm" "java-eclipse-sisu-inject"
                     "java-javax-inject" "java-plexus-component-annotations"
                     "java-plexus-utils" "java-plexus-interpolation"
                     "java-plexus-sec-dispatcher" "java-plexus-cipher" "java-guava"
                     "java-jansi" "java-jsr250" "java-cdi-api" "java-commons-cli"
                     "java-commons-io" "java-commons-lang3" "java-slf4j-api"
                     "java-slf4j-simple"))))
             (substitute* "apache-maven/src/bin/mvn"
               (("cygwin=false;")
                (string-append
                  "CLASSPATH="
                  (car (find-files
                         (assoc-ref inputs "java-plexus-classworlds")
                         ".*.jar"))
                  "\ncygwin=false;"))
               (("-classpath.*") "-classpath ${CLASSPATH} \\\n"))
             #t))
         (delete 'check)
         (replace 'install
           (lambda* (#:key outputs #:allow-other-keys)
             (let ((bin (string-append (assoc-ref outputs "out") "/bin/"))
                   (conf (string-append (assoc-ref outputs "out") "/conf/")))
               (mkdir-p (string-append (assoc-ref outputs "out") "/lib"))
               (for-each (lambda (file)
                           (install-file (string-append "apache-maven/src/bin/" file)
                                         bin)
                           (chmod (string-append bin file) #o755))
                '("mvn" "mvnDebug" "mvnyjp"))
               (install-file "apache-maven/src/bin/m2.conf" bin)
               (copy-recursively "apache-maven/src/conf" conf))
             #t)))))
    (inputs
     `(("java-plexus-classworlds" ,java-plexus-classworlds)
       ("maven-artifact" ,maven-artifact)
       ("maven-embedder" ,maven-embedder)
       ("maven-core" ,maven-core)
       ("maven-compat" ,maven-compat)
       ("maven-builder-support" ,maven-builder-support)
       ("maven-model" ,maven-model)
       ("maven-model-builder" ,maven-model-builder)
       ("maven-settings" ,maven-settings)
       ("maven-settings-builder" ,maven-settings-builder)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-repository-metadata" ,maven-repository-metadata)
       ("maven-shared-utils" ,maven-shared-utils)
       ("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-spi" ,maven-resolver-spi)
       ("maven-resolver-util" ,maven-resolver-util)
       ("maven-resolver-impl" ,maven-resolver-impl)
       ("maven-resolver-connector-basic" ,maven-resolver-connector-basic)
       ("maven-resolver-provider" ,maven-resolver-provider)
       ("maven-resolver-transport-wagon" ,maven-resolver-transport-wagon)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)
       ("maven-wagon-file" ,maven-wagon-file)
       ("maven-wagon-http" ,maven-wagon-http)
       ("java-commons-logging-minimal" ,java-commons-logging-minimal)
       ("java-httpcomponents-httpclient" ,java-httpcomponents-httpclient)
       ("java-httpcomponents-httpcore" ,java-httpcomponents-httpcore)
       ("maven-wagon-http-shared" ,maven-wagon-http-shared)
       ("maven-wagon-tck-http" ,maven-wagon-tck-http)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-guice" ,java-guice)
       ("java-aopalliance" ,java-aopalliance)
       ("java-cglib" ,java-cglib)
       ("java-asm" ,java-asm)
       ("java-eclipse-sisu-inject" ,java-eclipse-sisu-inject)
       ("java-javax-inject" ,java-javax-inject)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-plexus-sec-dispatcher" ,java-plexus-sec-dispatcher)
       ("java-plexus-cipher" ,java-plexus-cipher)
       ("java-guava" ,java-guava)
       ("java-jansi" ,java-jansi)
       ("java-jsr250" ,java-jsr250)
       ("java-cdi-api" ,java-cdi-api)
       ("java-commons-cli" ,java-commons-cli)
       ("java-commons-io" ,java-commons-io)
       ("java-commons-lang3" ,java-commons-lang3)
       ("java-slf4j-api" ,java-slf4j-api)
       ;; TODO: replace with maven-slf4j-provider
       ("java-slf4j-simple" ,java-slf4j-simple)))
    (propagated-inputs
     `(("coreutils" ,coreutils)
       ("which" ,which)))
    (description "Apache Maven is a software project management and comprehension
tool.  Based on the concept of a project object model: builds, dependency
management, documentation creation, site publication, and distribution
publication are all controlled from the @file{pom.xml} declarative file.  Maven
can be extended by plugins to utilise a number of other development tools for
reporting or the build process.")))

;; Many plugins require maven 3.0 as a dependency.
(define maven-3.0-pom
  (package
    (inherit maven-pom)
    (version "3.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/apache/maven")
                     (commit (string-append "maven-" version))))
              (file-name (git-file-name "maven" version))
              (sha256
               (base32
                "06jdwxx9w24shhv3kca80rlrikynn7kdqcrwg59lv2b7adpllwnh"))
              (modules '((guix build utils)))
              (snippet
               '(begin
                  (for-each delete-file (find-files "." "\\.jar$"))
                  (for-each (lambda (file) (chmod file #o644))
                            (find-files "." "."))
                  #t))
              (patches
                (search-patches "maven-generate-component-xml.patch"
                                "maven-generate-javax-inject-named.patch"))))
    (propagated-inputs
     `(("maven-parent-pom-15" ,maven-parent-pom-15)))))

(define-public maven-3.0-artifact
  (package
    (inherit maven-artifact)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (propagated-inputs
      (map
        (lambda (input)
          (if (equal? (car input) "maven-pom")
              `("maven-pom" ,maven-3.0-pom)
              input))
        (package-propagated-inputs maven-artifact)))))

(define-public maven-3.0-model
  (package
    (inherit maven-model)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (propagated-inputs
      (map
        (lambda (input)
          (if (equal? (car input) "maven-pom")
              `("maven-pom" ,maven-3.0-pom)
              input))
        (package-propagated-inputs maven-artifact)))
    (arguments
     `(#:jar-name "maven-model.jar"
       #:source-dir "maven-model/src/main/java"
       #:test-dir "maven-model/src/test"
       #:modules
       ((guix build ant-build-system)
        (guix build java-utils)
        (guix build syscalls)
        (guix build utils))
       #:phases
       (modify-phases %standard-phases
         (add-after 'configure 'use-newer-model
           (lambda* (#:key inputs #:allow-other-keys)
             ;; The model has almost not changed, but the newer version is
             ;; needed to prevent an error in the newer modello we have
             (let ((source (assoc-ref inputs "maven-source"))
                   (dir (mkdtemp! "maven-source-XXXXXXXX")))
               (with-directory-excursion dir
                 (invoke "tar" "xf" source)
                 (copy-file (car (find-files "." "maven.mdo"))
                            "../maven-model/src/main/mdo/maven.mdo")))
             #t))
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "maven-model/src/main/java" version
                       "false" "true" "UTF-8"))
             (let ((file "maven-model/src/main/mdo/maven.mdo"))
               (modello-single-mode file "4.0.0" "java")
               (modello-single-mode file "4.0.0" "xpp3-reader")
               (modello-single-mode file "4.0.0" "xpp3-writer")
               (modello-single-mode file "4.0.0" "xpp3-extended-reader"))
             #t))
         (replace 'install
           (install-from-pom "maven-model/pom.xml")))))
    (inputs
      `(("maven-source" ,(package-source maven-pom))
        ,@(package-inputs maven-model)))))

(define-public maven-3.0-settings
  (package
    (inherit maven-settings)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (propagated-inputs
      (map
        (lambda (input)
          (if (equal? (car input) "maven-pom")
              `("maven-pom" ,maven-3.0-pom)
              input))
        (package-propagated-inputs maven-settings)))))

(define-public maven-3.0-settings-builder
  (package
    (inherit maven-settings-builder)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (propagated-inputs
     `(("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ,@(filter
           (lambda (a) a)
           (map
             (lambda (input)
               (match (car input)
                 ("maven-pom" `("maven-pom" ,maven-3.0-pom))
                 ("maven-settings" `("maven-settings" ,maven-3.0-settings))
                 ("maven-builder-support" #f)
                 (_ input)))
             (package-propagated-inputs maven-settings-builder)))))))

(define-public maven-3.0-model-builder
  (package
    (inherit maven-model-builder)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (propagated-inputs
     `(("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ,@(filter
           (lambda (a) a)
           (map
             (lambda (input)
               (match (car input)
                 ("maven-pom" `("maven-pom" ,maven-3.0-pom))
                 ("maven-model" `("maven-model" ,maven-3.0-model))
                 ("maven-artifact" `("maven-artifact" ,maven-3.0-artifact))
                 ("maven-builder-support" #f)
                 (_ input)))
             (package-propagated-inputs maven-model-builder)))))))

(define-public maven-3.0-plugin-api
  (package
    (inherit maven-plugin-api)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (arguments
      (substitute-keyword-arguments (package-arguments maven-plugin-api)
        ((#:phases phases)
         `(modify-phases ,phases
            (add-before 'install 'fix-pom
              (lambda _
                (substitute* "maven-plugin-api/pom.xml"
                  (("org.sonatype.sisu") "org.codehaus.plexus")
                  (("sisu-inject-plexus") "plexus-container-default"))
                #t))))))
    (propagated-inputs
      (map
        (lambda (input)
          (match (car input)
            ("maven-pom" `("maven-pom" ,maven-3.0-pom))
            ("maven-artifact" `("maven-artifact" ,maven-3.0-artifact))
            ("maven-model" `("maven-model" ,maven-3.0-model))
            (_ input)))
        (package-propagated-inputs maven-model-builder)))
    (native-inputs
     `(("java-plexus-container-default" ,java-plexus-container-default)
       ,@(package-native-inputs maven-plugin-api)))))

(define-public maven-3.0-repository-metadata
  (package
    (inherit maven-repository-metadata)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (propagated-inputs
      (map
        (lambda (input)
          (if (equal? (car input) "maven-pom")
              `("maven-pom" ,maven-3.0-pom)
              input))
        (package-propagated-inputs maven-repository-metadata)))))

(define-public maven-3.0-aether-provider
  (package
    (inherit maven-3.0-pom)
    (name "maven-aether-provider")
    (arguments
     `(#:jar-name "maven-aether-provider.jar"
       #:source-dir "maven-aether-provider/src/main/java"
       #:tests? #f; no tests in 3.0
       #:phases
       (modify-phases %standard-phases
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t))
         (replace 'install
           (install-from-pom "maven-aether-provider/pom.xml")))))
    (propagated-inputs
     `(("maven-model" ,maven-3.0-model)
       ("maven-model-builder" ,maven-3.0-model-builder)
       ("maven-repository-metadata" ,maven-3.0-repository-metadata)
       ("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-sonatype-aether-spi" ,java-sonatype-aether-spi)
       ("java-sonatype-aether-impl" ,java-sonatype-aether-impl)
       ("java-plexus-component-annotation" ,java-plexus-component-annotations)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-pom" ,maven-3.0-pom)))
    (native-inputs
     `(("java-plexus-component-metadata" ,java-plexus-component-metadata)))))

(define-public maven-3.0-core
  (package
    (inherit maven-core)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (arguments
     `(#:jar-name "maven-core.jar"
       #:source-dir "src/main/java"
       #:tests? #f
       #:phases
       (modify-phases %standard-phases
         (add-before 'configure 'chdir
           (lambda _
             ;; Required for generating components.xml in maven-core
             (chdir "maven-core")
             #t))
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java" "org.codehaus.modello.ModelloCli"
                       file mode "src/main/java" version
                       "false" "true" "UTF-8"))
             (let ((file "src/main/mdo/toolchains.mdo"))
               (modello-single-mode file "1.0.0" "java")
               (modello-single-mode file "1.0.0" "xpp3-reader")
               (modello-single-mode file "1.0.0" "xpp3-writer"))
             #t))
         (add-before 'build 'copy-resources
           (lambda _
             (mkdir-p "build/classes/")
             (copy-recursively "src/main/resources" "build/classes")
             #t))
         (add-after 'build 'generate-metadata
           (lambda _
             (define (components file)
               (let ((sxml (with-input-from-file file
                             (lambda _ (xml->sxml (current-input-port)
                                                  #:trim-whitespace? #t)))))
                 ;; Select the list of <component>s inside the <component-set>
                 ;; and <components>.
                 ((@ (ice-9 match) match) sxml
                  (('*TOP*
                    ('*PI* foo ...)
                    ('component-set
                     ('components x ...))) x))))
             (use-modules (sxml simple))
             (delete-file "build/classes/META-INF/plexus/components.xml")
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "build/classes/META-INF/plexus"
                     "--output" "build/classes/META-INF/plexus/components.t.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes")
             ;; Now we merge all other components from hand-written xml
             (let ((generated-xml (components "build/classes/META-INF/plexus/components.t.xml"))
                   (components-xml (components "src/main/resources/META-INF/plexus/components.xml"))
                   (artifact-handlers-xml (components "src/main/resources/META-INF/plexus/artifact-handlers.xml")))
               (with-output-to-file "build/classes/META-INF/plexus/components.xml"
                 (lambda _
                   (display "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
                   (sxml->xml
                     `(component-set
                        (components
                          ,@(append generated-xml components-xml
                                    artifact-handlers-xml)))))))
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t))
         (add-before 'install 'fix-pom
           (lambda _
             (substitute* "pom.xml"
               (("org.sonatype.sisu") "org.codehaus.plexus")
               (("sisu-inject-plexus") "plexus-container-default"))
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-model" ,maven-3.0-model)
       ("maven-settings" ,maven-3.0-settings)
       ("maven-settings-builder" ,maven-3.0-settings-builder)
       ("maven-repository-metadata" ,maven-3.0-repository-metadata)
       ("maven-artifact" ,maven-3.0-artifact)
       ("maven-model-builder" ,maven-3.0-model-builder)
       ("maven-aether-provider" ,maven-3.0-aether-provider)
       ("java-sonatype-aether-impl" ,java-sonatype-aether-impl)
       ("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-sonatype-aether-util" ,java-sonatype-aether-util)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("java-plexus-sec-dispatcher" ,java-plexus-sec-dispatcher)
       ("maven-pom" ,maven-3.0-pom)))))

(define-public maven-3.0-compat
  (package
    (inherit maven-compat)
    (version (package-version maven-3.0-pom))
    (source (package-source maven-3.0-pom))
    (arguments
     `(#:tests? #f ;require an old version of java-easymock
       ,@(substitute-keyword-arguments (package-arguments maven-compat)
          ((#:phases phases)
           `(modify-phases ,phases
              (add-before 'install 'fix-pom
                (lambda _
                  (substitute* "pom.xml"
                    (("org.sonatype.sisu") "org.codehaus.plexus")
                    (("sisu-inject-plexus") "plexus-container-default"))
                  #t))
              (delete 'build-tests))))))
    (propagated-inputs
     `(("maven-model" ,maven-3.0-model)
       ("maven-model-builder" ,maven-3.0-model-builder)
       ("maven-settings" ,maven-3.0-settings)
       ("maven-settings-builder" ,maven-3.0-settings-builder)
       ("maven-artifact" ,maven-3.0-artifact)
       ("maven-core" ,maven-3.0-core)
       ("maven-aether-provider" ,maven-3.0-aether-provider)
       ("maven-repository-metadata" ,maven-3.0-repository-metadata)
       ("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-sonatype-aether-util" ,java-sonatype-aether-util)
       ("java-sonatype-aether-impl" ,java-sonatype-aether-impl)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-eclipse-sisu-plexus" ,java-eclipse-sisu-plexus)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)
       ("maven-pom" ,maven-3.0-pom)))))

(define-public maven-shared-utils-3.0
  (package
    (inherit maven-shared-utils)
    (version "3.0.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://archive.apache.org/dist/maven/shared/"
                                  "maven-shared-utils-" version "-source-release.zip"))
              (sha256
               (base32
                "0qm8y85kip2hyhnhlkqgj0rhmf83z07s7l7gzsfl5dzl3kvp8nal"))))
    (propagated-inputs
     `(("maven-core" ,maven-3.0-core)
       ("maven-components-parent-pom" ,maven-components-parent-pom-21)
       ,@(package-propagated-inputs maven-shared-utils)))))

(define-public maven-shared-utils-3.1
  (package
    (inherit maven-shared-utils)
    (version "3.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://archive.apache.org/dist/maven/shared/"
                                  "maven-shared-utils-" version "-source-release.zip"))
              (sha256
               (base32
                "0vfaas4g09ch0agrd1dcxcmhdd3w971ssvfr9mx9gi2lp5nv8w66"))))))

(define-public maven-shared-io
  (package
    (name "maven-shared-io")
    (version "3.0.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "maven-shared-io-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "0hsyll8gg581802xhs4achdz8fpmfz7y02abx9s4mb8bc6yfh229"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-shared-io.jar"
       #:source-dir "src/main/java"
       #:test-dir "src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'copy-resources
           (lambda _
             (copy-recursively "src/main/resources" "build/classes/")
             (copy-recursively "src/test/resources" "build/test-classes/")
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-3.0-artifact)
       ("maven-compat" ,maven-3.0-compat)
       ("maven-plugin-api" ,maven-3.0-plugin-api)
       ("maven-shared-utils" ,maven-shared-utils)
       ("maven-wagon-provider-api" ,maven-wagon-provider-api)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-components-parent-pom" ,maven-components-parent-pom-22)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-junit" ,java-junit)
       ("java-easymock" ,java-easymock)))
    (home-page "https://maven.apache.org/shared/maven-dependency-tree")
    (synopsis "Tree-based API for resolution of Maven project dependencies")
    (description "This package provides a tree-based API for resolution of
Maven project dependencies.")
    (license license:asl2.0)))

(define-public maven-file-management
  (package
    (name "maven-file-management")
    (version "3.0.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "file-management-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "0wisz6sm67axrwvx8a75mb9s03h7kzkzfw8j3aaa4sx4k9ph58da"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-file-management.jar"
       #:source-dir "src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'copy-resources
           (lambda _
             (copy-recursively "src/main/resources" "build/classes/")
             #t))
         (add-before 'build 'generate-models
           (lambda* (#:key inputs #:allow-other-keys)
             (define (modello-single-mode file version mode)
               (invoke "java"
                       "org.codehaus.modello.ModelloCli"
                       file mode "src/main/java" version
                       "false" "true"))
             (let ((file "src/main/mdo/fileset.mdo"))
               (modello-single-mode file "1.1.0" "java")
               (modello-single-mode file "1.1.0" "xpp3-reader")
               (modello-single-mode file "1.1.0" "xpp3-writer"))
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-plugin-api" ,maven-3.0-plugin-api)
       ("maven-shared-io" ,maven-shared-io)
       ("maven-shared-utils" ,maven-shared-utils)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-components-parent-pom" ,maven-components-parent-pom-22)))
    (native-inputs
     `(("java-modello-core" ,java-modello-core)
       ;; modello plugins:
       ("java-modellop-plugins-java" ,java-modello-plugins-java)
       ("java-modellop-plugins-xpp3" ,java-modello-plugins-xpp3)
       ("unzip" ,unzip)))
    (home-page "https://maven.apache.org/shared/maven-dependency-tree")
    (synopsis "Tree-based API for resolution of Maven project dependencies")
    (description "This package provides a tree-based API for resolution of
Maven project dependencies.")
    (license license:asl2.0)))

(define-public maven-archiver
  (package
    (name "maven-archiver")
    (version "3.5.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "maven-archiver-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "1204xkqj259brpk3yscprml0lbfbyn1vn5nrgqjk44z5vx127lbw"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-archiver.jar"
       #:source-dir "src/main/java"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("java-commons-io" ,java-commons-io)
       ("maven-artifact" ,maven-3.0-artifact)
       ("maven-core" ,maven-3.0-core)
       ("maven-model" ,maven-3.0-model)
       ("maven-shared-utils" ,maven-shared-utils)
       ("java-plexus-archiver" ,java-plexus-archiver)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maen-parent-pom" ,maven-parent-pom-33)))
    (native-inputs
     `(("java-junit" ,java-junit)
       ("java-assertj" ,java-assertj)
       ("unzip" ,unzip)))
    (home-page "https://maven.apache.org/shared/maven-dependency-tree")
    (synopsis "Tree-based API for resolution of Maven project dependencies")
    (description "This package provides a tree-based API for resolution of
Maven project dependencies.")
    (license license:asl2.0)))

(define-public maven-dependency-tree
  (package
    (name "maven-dependency-tree")
    (version "3.0.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "maven-dependency-tree-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "0mxfslxvcmjs13jl30zhcg672j970dzn6ihh79w9ajh6sfqmlds2"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-dependency-tree.jar"
       #:source-dir "src/main/java"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-core" ,maven-3.0-core)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("maven-parent-pom" ,maven-parent-pom-30)))
    (inputs
     `(("java-sonatype-aether-api"  ,java-sonatype-aether-api)
       ("java-sonatype-aether-util" ,java-sonatype-aether-util)
       ("java-eclipse-aether-api" ,java-eclipse-aether-api)
       ("java-eclipse-aether-util" ,java-eclipse-aether-util)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-junit" ,java-junit)))
    (home-page "https://maven.apache.org/shared/maven-dependency-tree")
    (synopsis "Tree-based API for resolution of Maven project dependencies")
    (description "This package provides a tree-based API for resolution of
Maven project dependencies.")
    (license license:asl2.0)))

(define-public maven-common-artifact-filters
  (package
    (name "maven-common-artifact-filters")
    (version "3.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "maven-common-artifact-filters-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "1cl1qk4r0gp62bjzfm7lml9raz1my2kd4yf0ci0lnfsn0h5qivnb"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-common-artifact-filters.jar"
       #:source-dir "src/main/java"
       #:tests? #f; require maven-plugin-testing-harness, which requires maven 3.2.
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'remove-sisu
           (lambda _
             ;; Replace sisu with an existing dependency, to prevent a failure
             ;; when rewritting dependency versions
             (substitute* "pom.xml"
               (("sisu-inject-plexus") "maven-plugin-api")
               (("org.sonatype.sisu") "org.apache.maven"))
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-3.0-artifact)
       ("maven-model" ,maven-3.0-model)
       ("maven-core" ,maven-3.0-core)
       ("maven-plugin-api" ,maven-3.0-plugin-api)
       ("maven-shared-utils" ,maven-shared-utils)
       ("maven-parent-pom" ,maven-parent-pom-33)
       ("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-sonatype-aether-util" ,java-sonatype-aether-util)))
    (inputs
     `(("maven-resolver-api" ,maven-resolver-api)
       ("maven-resolver-util" ,maven-resolver-util)))
    (native-inputs
     `(("unzip" ,unzip)))
   (home-page "https://maven.apache.org/shared/maven-dependency-tree")
    (synopsis "Tree-based API for resolution of Maven project dependencies")
    (description "This package provides a tree-based API for resolution of
Maven project dependencies.")
    (license license:asl2.0)))

(define-public maven-enforcer-api
  (package
    (name "maven-enforcer-api")
    (version "3.0.0-M3")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/enforcer/"
                                  "enforcer-" version "-source-release.zip"))
              (sha256
               (base32
                "014cwj0dqa69nnlzcin8pk9wsjmmg71vsbcpb16cibcjpm6h9wjg"))
              (patches
                (search-patches "maven-enforcer-api-fix-old-dependencies.patch"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-enforcer-api.jar"
       #:source-dir "enforcer-api/src/main/java"
       #:tests? #f; no tests
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "enforcer-api/pom.xml")))))
    (propagated-inputs
     `(("maven-plugin-api" ,maven-plugin-api)
       ("java-plexus-container-default" ,java-plexus-container-default)
       ("java-jsr305" ,java-jsr305)
       ("maven-enforcer-parent-pom" ,maven-enforcer-parent-pom)))
    (native-inputs
     `(("unzip" ,unzip)))
    (home-page "https://maven.apache.org/shared/maven-dependency-tree")
    (synopsis "Tree-based API for resolution of Maven project dependencies")
    (description "This package provides a tree-based API for resolution of
Maven project dependencies.")
    (license license:asl2.0)))

(define maven-enforcer-parent-pom
  (package
    (inherit maven-enforcer-api)
    (name "maven-enforcer-parent-pom")
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (replace 'install
           (install-pom-file "pom.xml")))))
    (propagated-inputs
     `(("maven-parent-pom" ,maven-parent-pom-30)))))

(define-public maven-enforcer-rules
  (package
    (inherit maven-enforcer-api)
    (name "maven-enforcer-rules")
    (arguments
     `(#:tests? #f; requires maven-plugin-testing-harness
       #:jar-name "maven-enforcer-rules.jar"
       #:source-dir "enforcer-rules/src/main/java"
       #:test-dir "enforcer-rules/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "enforcer-rules/pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-artifact)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-core" ,maven-core)
       ("maven-common-artifact-filters" ,maven-common-artifact-filters)
       ("java-commons-codec" ,java-commons-codec)
       ("java-commons-lang3" ,java-commons-lang3)
       ("maven-enforcer-api" ,maven-enforcer-api)
       ("maven-resolver-util" ,maven-resolver-util)
       ("java-bsh" ,java-bsh)
       ("maven-dependency-tree" ,maven-dependency-tree)
       ("maven-compat" ,maven-3.0-compat)
       ("maven-enforcer-parent-pom" ,maven-enforcer-parent-pom)))))

(define-public maven-enforcer-plugin
  (package
    (inherit maven-enforcer-api)
    (name "maven-enforcer-plugin")
    (arguments
     `(#:tests? #f
       #:jar-name "maven-enforcer-plugin.jar"
       #:source-dir "maven-enforcer-plugin/src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-plugin.xml
           (generate-plugin.xml "maven-enforcer-plugin/pom.xml"
             "enforcer"
             "maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/"
             (list
               (list "DisplayInfoMojo.java")
               (list "EnforceMojo.java"))))
         (replace 'install
           (install-from-pom "maven-enforcer-plugin/pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-artifact)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-core" ,maven-core)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-enforcer-api" ,maven-enforcer-api)
       ("maven-enforcer-rules" ,maven-enforcer-rules)
       ("maven-plugin-annotations" ,maven-plugin-annotations)
       ("maven-enforcer-parent-pom" ,maven-enforcer-parent-pom)))))

(define-public maven-artifact-transfer
  (package
    (name "maven-artifact-transfer")
    (version "0.12.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/shared/"
                                  "maven-artifact-transfer-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "0mkdjr3wnvaxqaq68sy7h4mqlq3xgwwp5s2anj5vbxfy4bsc1ivj"))))
    (build-system ant-build-system)
    (arguments
     `(#:tests? #f; require mockito 2
       #:jar-name "maven-artifact-transfer.jar"
       #:source-dir "src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("java-commons-codec" ,java-commons-codec)
       ("maven-artifact" ,maven-3.0-artifact)
       ("maven-core" ,maven-3.0-core)
       ("maven-common-artifact-filters" ,maven-common-artifact-filters)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-slf4j-api" ,java-slf4j-api)
       ("java-plexus-classworlds" ,java-plexus-classworlds)
       ("java-sonatype-aether-api" ,java-sonatype-aether-api)
       ("java-eclipse-aether-api" ,java-eclipse-aether-api)
       ("java-eclipse-aether-util" ,java-eclipse-aether-util)
       ("java-eclipse-aether-impl" ,java-eclipse-aether-impl)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)))
    (home-page "https://maven.apache.org/shared/maven-artifact-transfer")
    (synopsis "API to install, deploy and resolve artifacts in Maven")
    (description "This package contains an API to install, deploy and resolve
artifacts in Maven 3.")
    (license license:asl2.0)))

(define-public maven-install-plugin
  (package
    (name "maven-install-plugin")
    (version "3.0.0-M1")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/plugins/"
                                  "maven-install-plugin-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "1l9iydxririrair0i5sk2iypn9wspzbb666lc0ddg20yyr8w39dm"))))
    (build-system ant-build-system)
    (arguments
     `(#:tests? #f; require maven-plugin-testing-harness
       #:jar-name "maven-install-plugin.jar"
       #:source-dir "src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'fix-pom
           (lambda _
             (substitute* "pom.xml"
               (("maven-project") "maven-core")
               (("maven-artifact-manager") "maven-artifact")
               (("2.0.6") "3.0"))
             #t))
         (add-before 'build 'generate-plugin.xml
           (generate-plugin.xml "pom.xml"
             "install"
             "src/main/java/org/apache/maven/plugins/install"
             (list
               (list "AbstractInstallMojo.java" "InstallFileMojo.java")
               (list "AbstractInstallMojo.java" "InstallMojo.java"))))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-artifact" ,maven-artifact)
       ("maven-plugin-api" ,maven-plugin-api)
       ("maven-compat" ,maven-compat)
       ("maven-artifact-transfer" ,maven-artifact-transfer)
       ("maven-plugins-pom-23" ,maven-plugins-pom-23)
       ("java-plexus-digest" ,java-plexus-digest)))
    (inputs
     `(("maven-plugin-annotations" ,maven-plugin-annotations)
       ("java-slf4j-api" ,java-slf4j-api)))
    (native-inputs
     `(("unzip" ,unzip)))
    (home-page "https://maven.apache.org/plugin/maven-install-plugin")
    (synopsis "Maven's install plugin")
    (description "The Install Plugin is used during the install phase to add
artifact(s) to the local repository.  The Install Plugin uses the information
in the POM (groupId, artifactId, version) to determine the proper location for
the artifact within the local repository.

The local repository is the local cache where all artifacts needed for the
build are stored.  By default, it is located within the user's home directory
(@file{~/.m2/repository}) but the location can be configured in
@file{~/.m2/settings.xml} using the @code{<localRepository>} element.")
    (license license:asl2.0)))

(define-public maven-filtering
  (package
    (name "maven-filtering")
    (version "3.1.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://archive.apache.org/dist/maven/"
                                  "shared/maven-filtering-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "09wrdhchnszd2l6h4z30ra0bv1a19qyjgac9z8zf1pn0m4nw05yz"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-filtering.jar"
       #:source-dir "src/main/java"
       #:test-dir "src/test"
       ;; this test comes from sisu-build-api, not this package
       #:test-exclude (list "**/IncrementalResourceFilteringTest.java"
                            "**/Abstract*.java")
       #:phases
       (modify-phases %standard-phases
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (add-after 'generate-metadata 'rebuild
           (lambda _
             (invoke "ant" "jar")
             #t))
         (add-before 'check 'decompress-tests
           (lambda* (#:key inputs #:allow-other-keys)
             (let* ((build-api-source (assoc-ref inputs "java-sisu-build-api-origin"))
                    (classes (string-append build-api-source "/src/test/java")))
               (copy-recursively classes "src/test/"))
             #t))
         (add-before 'check 'fix-directory
           (lambda _
             (substitute* (find-files "src/test" ".*.java$")
               (("target/test-classes/") "build/test-classes/"))))
         (add-before 'check 'copy-test-resources
           (lambda _
             (copy-recursively "src/test/resources" "build/test-classes/")
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-core" ,maven-3.0-core)
       ("maven-shared-utils" ,maven-shared-utils)
       ("java-plexus-utils" ,java-plexus-utils)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("java-sisu-build-api" ,java-sisu-build-api)
       ("maven-parent-pom" ,maven-parent-pom-30)))
    (inputs
     `(("java-jsr305" ,java-jsr305)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-assertj" ,java-assertj)
       ("java-junit" ,java-junit)
       ("java-mockito" ,java-mockito-1)
       ("java-objenesis" ,java-objenesis)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)
       ("java-sisu-build-api-origin" ,(package-source java-sisu-build-api))))
    (home-page "https://maven.apache.org/shared/maven-filtering")
    (synopsis "Shared component for all plugins that needs to filter resources")
    (description "This component provides an API to filter resources in Maven
projects.")
    (license license:asl2.0)))

(define-public maven-resources-plugin
  (package
    (name "maven-resources-plugin")
    (version "3.1.0")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/apache/"
                                  "maven-resources-plugin/archive/"
                                  "maven-resources-plugin-" version ".tar.gz"))
              (sha256
               (base32
                "1f5gnjg2xmqfxml6k0ydyd1sxxwzgnb24qn6avcc4mijwd8a84pl"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-resources-plugin.jar"
       #:source-dir "src/main/java"
       #:test-dir "src/test"
       #:tests? #f; test depends on maven-plugin-test-harness
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-plugin.xml
           (generate-plugin.xml "pom.xml" "resources"
             "src/main/java/org/apache/maven/plugins/resources"
             (list
               (list "ResourcesMojo.java" "CopyResourcesMojo.java")
               (list "ResourcesMojo.java")
               (list "ResourcesMojo.java" "TestResourcesMojo.java"))))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-plugin-api" ,maven-plugin-api)
       ("maven-core" ,maven-core)
       ("java-plexus-utils" ,java-plexus-utils)
       ("maven-filtering" ,maven-filtering)
       ("java-plexus-interpolation" ,java-plexus-interpolation)
       ("maven-parent-pom" ,maven-parent-pom-31)))
    (inputs
     `(("maven-plugin-annotations" ,maven-plugin-annotations)
       ("java-commons-io" ,java-commons-io)))
    (native-inputs
     `(("java-plexus-component-metadata" ,java-plexus-component-metadata)))
    (home-page "https://maven.apache.org/plugins/maven-resources-plugin")
    (synopsis "Maven plugin to collect and install resources")
    (description "The Resources Plugin handles the copying of project resources
to the output directory.  There are two different kinds of resources: main
resources and test resources.  The difference is that the main resources are
the resources associated to the main source code while the test resources are
associated to the test source code.

Thus, this allows the separation of resources for the main source code and its
unit tests.")
    (license license:asl2.0)))

(define-public maven-shared-incremental
  (package
    (name "maven-shared-incremental")
    (version "1.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://archive.apache.org/dist/maven/shared/"
                                  "maven-shared-incremental-" version
                                  "-source-release.zip"))
              (sha256
               (base32
                "03n4nfswyg9ahkz2zx4skcr3ghs01zh95g9js51hc75mfqx9b976"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "shared-incremental.java"
       #:source-dir "src/main/java"
       #:test-dir "src/test"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'change-parent
           (lambda _
             (substitute* "pom.xml"
               (("19") "30"))
             #t))
         (add-before 'build 'fix-pom
           (lambda _
             (substitute* "pom.xml"
               (("plexus-component-api") "plexus-component-annotations"))
             #t))
         (add-after 'build 'generate-metadata
           (lambda _
             (invoke "java" "-cp" (string-append (getenv "CLASSPATH") ":build/classes")
                     "org.codehaus.plexus.metadata.PlexusMetadataGeneratorCli"
                     "--source" "src/main/java"
                     "--output" "build/classes/META-INF/plexus/components.xml"
                     "--classes" "build/classes"
                     "--descriptors" "build/classes/META-INF")
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-plugin-api" ,maven-plugin-api)
       ("maven-core" ,maven-core)
       ("maven-shared-utils" ,maven-shared-utils)
       ("java-plexus-component-annotations" ,java-plexus-component-annotations)
       ("maven-parent-pom" ,maven-parent-pom-30)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-plexus-component-metadata" ,java-plexus-component-metadata)))
    (home-page "https://maven.apache.org/shared/maven-shared-incremental")
    (synopsis "Maven Incremental Build support utilities")
    (description "This package contains various utility classes and plexus
components for supporting incremental build functionality in maven plugins.")
    (license license:asl2.0)))

(define-public maven-compiler-plugin
  (package
    (name "maven-compiler-plugin")
    (version "3.8.1")
    (source (origin
              (method url-fetch)
              (uri (string-append "https://github.com/apache/"
                                  "maven-compiler-plugin/archive/"
                                  "maven-compiler-plugin-" version ".tar.gz"))
              (sha256
               (base32
                "018d9qwc4cd6k7a8kvhvxjmzbzd2ifdf7m36wqjfq42010js1mv1"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-compiler-plugin.jar"
       #:source-dir "src/main/java"
       #:test-dir "src/test"
       #:tests? #f; test depends on maven-plugin-test-harness
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-plugin.xml
           (generate-plugin.xml "pom.xml"
             "compiler"
             "src/main/java/org/apache/maven/plugin/compiler"
             (list
               (list "AbstractCompilerMojo.java" "CompilerMojo.java")
               (list "AbstractCompilerMojo.java" "TestCompilerMojo.java"))))
         (add-after 'generate-plugin.xml 'fix-plugin.xml
           (lambda _
             (substitute* "build/classes/META-INF/maven/plugin.xml"
               ;; These are defined in AbstractCompilerMojo.java, but not
               ;; parsed correctly in the previous phase
               (("DEFAULT_TARGET") "1.6")
               (("DEFAULT_SOURCE") "1.6"))
             #t))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-plugin-api" ,maven-plugin-api)
       ("maven-artifact" ,maven-artifact)
       ("maven-core" ,maven-core)
       ("maven-shared-utils" ,maven-shared-utils)
       ("maven-shared-incremental" ,maven-shared-incremental)
       ("java-plexus-java" ,java-plexus-java)
       ("java-plexus-compiler-api" ,java-plexus-compiler-api)
       ("java-plexus-compiler-manager" ,java-plexus-compiler-manager)
       ("java-plexus-compiler-javac" ,java-plexus-compiler-javac)
       ("maven-parent-pom" ,maven-parent-pom-33)))
    (inputs
     `(("maven-plugin-annotations" ,maven-plugin-annotations)
       ("java-commons-io" ,java-commons-io)))
    (home-page "https://maven.apache.org/plugins/maven-compiler-plugin")
    (synopsis "Compiler plugin for Maven")
    (description "The Compiler Plugin is used to compile the sources of your
project.  Since 3.0, the default compiler is @code{javax.tools.JavaCompiler}
(if you are using java 1.6) and is used to compile Java sources.  If you want
to force the plugin using javac, you must configure the plugin option
@code{forceJavacCompilerUse}.

Also note that at present the default source setting is 1.6 and the default
target setting is 1.6, independently of the JDK you run Maven with.  You are
highly encouraged to change these defaults by setting source and target as
described in Setting the -source and -target of the Java Compiler.

Other compilers than javac can be used and work has already started on
AspectJ, .NET, and C#.")
    (license license:asl2.0)))

(define-public java-surefire-logger-api
  (package
    (name "java-surefire-logger-api")
    (version "3.0.0-M4")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://apache/maven/surefire/"
                                  "surefire-" version "-source-release.zip"))
              (sha256
               (base32
                "1s6d4pzk3bjm9l38mj9sfgbgmk145rppdj1dmqwc4d5105mr9q9w"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "java-surefire-logger-api.jar"
       #:source-dir "surefire-logger-api/src/main/java"
       #:tests? #f; require mockito 2
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "surefire-logger-api/pom.xml")))))
    (propagated-inputs
     `(("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (native-inputs
     `(("unzip" ,unzip)))
    (home-page "https://maven.apache.org/surefire/surefire-logger-api")
    (synopsis "Interfaces and Utilities related only to internal SureFire Logger API")
    (description "This package contains interfaces and utilities that are
internal to the SureFire Logger API.  It is designed to have no dependency.")
    (license license:asl2.0)))

(define-public java-surefire-parent-pom
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-parent-pom")
    (arguments
     `(#:tests? #f
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
         (delete 'build)
         (add-before 'install 'fix-pom-dependency-versions
           (lambda _
             (substitute* "pom.xml"
               (("1.11") ,(package-version java-commons-compress))
               (("1.13") ,(package-version java-commons-codec)))
             (substitute* "pom.xml"
               (("commonsLang3Version>.*")
                (string-append
                  "commonsLang3Version>"
                  ,(package-version java-commons-lang3)
                  "</commonsLang3Version>\n"))
               (("commonsCompress>.*")
                (string-append
                  "commonsCompress>"
                  ,(package-version java-commons-compress)
                  "</commonsCompress>\n"))
               (("commonsIoVersion>.*")
                (string-append
                  "commonsIoVersion>"
                  ,(package-version java-commons-io)
                  "</commonsIoVersion>\n"))
               (("0.11.0") ,(package-version maven-artifact-transfer))
               (("1.0.3") ,(package-version java-plexus-java)))
             #t))
         (add-after 'install 'install-providers
           (install-pom-file "surefire-providers/pom.xml"))
         (replace 'install
           (install-pom-file "pom.xml")))))
    (propagated-inputs
     `(("maven-parent-pom" ,maven-parent-pom-33)))))

(define-public java-surefire-api
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-api")
    (arguments
     `(#:tests? #f
       #:jar-name "java-surefire-api.jar"
       #:source-dir "surefire-api/src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'copy-resources
           (lambda _
             (mkdir-p "build/classes")
             (copy-recursively "surefire-api/src/main/resources" "build/classes")
             #t))
         (add-before 'build 'prepare-shade
           (lambda* (#:key inputs #:allow-other-keys)
             (mkdir-p "build/classes")
             (with-directory-excursion "build/classes"
               (for-each
                 (lambda (input)
                   (for-each
                     (lambda (jar-file)
                       (invoke "jar" "xf" jar-file)
                       (delete-file-recursively "META-INF"))
                     (find-files (assoc-ref inputs input) ".*.jar$")))
                 '("maven-shared-utils" "java-commons-codec")))
             #t))
         (add-after 'build 'shade
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((jarjar
                   (car (find-files (assoc-ref inputs "java-jarjar") ".*.jar$")))
                   (injar "java-surefire-api.jar")
                   (outjar "java-surefire-api-shaded.jar"))
               (with-directory-excursion "build/jar"
                 (with-output-to-file "rules"
                   (lambda _
                     (format #t (string-append
                                  "rule "
                                  "org.apache.maven.shared.utils.** "
                                  "org.apache.maven.surefire.shade.api."
                                  "org.apache.maven.shared.utils.@1~%"))
                     (format #t (string-append
                                  "rule "
                                  "org.apache.commons.codec.** "
                                  "org.apache.maven.surefire.shade.api."
                                  "org.apache.commons.codec.@1~%"))))
                 (invoke "java" "-jar" jarjar "process" "rules" injar outjar)
                 (delete-file injar)
                 (rename-file outjar injar)))
             #t))
         (replace 'install
           (install-from-pom "surefire-api/pom.xml")))))
    (propagated-inputs
     `(("java-surefire-logger-api" ,java-surefire-logger-api)
       ("java-commons-codec" ,java-commons-codec)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)
       ("maven-shared-utils" ,maven-shared-utils-3.1)))
    (inputs
     `(("java-jsr305" ,java-jsr305)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-jarjar" ,java-jarjar)))
    (synopsis "Maven SureFire API")
    (description "This package contains the API to use Maven SureFire.")))

(define-public java-surefire-booter
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-booter")
    (arguments
     `(#:tests? #f; require mockito 2
       #:jar-name "java-surefire-booter.jar"
       #:source-dir "surefire-booter/src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'fix-/bin/sh
           (lambda _
             (substitute* "surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java"
               (("/bin/sh") (which "sh")))
             #t))
         (replace 'install
           (install-from-pom "surefire-booter/pom.xml")))))
    (propagated-inputs
     `(("java-surefire-api" ,java-surefire-api)
       ("java-commons-lang3" ,java-commons-lang3)
       ("java-commons-io" ,java-commons-io)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (inputs
     `(("java-jsr305" ,java-jsr305)))
    (synopsis "API and Facilities used by forked tests running in JVM sub-process")
    (description "SureFire runs tests inside a forked JVM subprocess.  This
package contains an API and facilities used inside that forked JVM.")))

(define-public java-surefire-extensions-api
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-extensions-api")
    (arguments
     `(#:tests? #f; requires mockito 2
       #:jar-name "java-surefire-extensions-api.jar"
       #:source-dir "surefire-extensions-api/src/main/java"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "surefire-extensions-api/pom.xml")))))
    (propagated-inputs
     `(("java-surefire-api" ,java-surefire-api)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (inputs
     `(("java-plexus-component-annotations" ,java-plexus-component-annotations)))
    (synopsis "Extension API for Maven SureFire")
    (description "Surefire is a test framework project.  This is the aggregator
POM in Apache Maven Surefire project.")))

(define-public java-surefire-common-java5
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-common-java5")
    (arguments
     `(#:jar-name "java-surefire-common-java5.jar"
       #:source-dir "surefire-providers/common-java5/src/main/java"
       #:test-dir "surefire-providers/common-java5/src/test"
       #:test-exclude (list
                        ;; Abstract class
                        "**/PojoStackTraceWriterTest.java"
                        ;; Fails
                        "**/SmartStackTraceParserTest.java")
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'prepare-shade
           (lambda* (#:key inputs #:allow-other-keys)
             (mkdir-p "build/classes")
             (with-directory-excursion "build/classes"
               (for-each
                 (lambda (jar-file)
                   (invoke "jar" "xf" jar-file)
                   (delete-file-recursively "META-INF"))
                 (find-files (assoc-ref inputs "maven-shared-utils") ".*.jar$")))
             #t))
         (add-after 'build 'shade
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((jarjar
                   (car (find-files (assoc-ref inputs "java-jarjar") ".*.jar$")))
                   (injar "java-surefire-common-java5.jar")
                   (outjar "java-surefire-common-java5-shaded.jar"))
               (with-directory-excursion "build/jar"
                 (with-output-to-file "rules"
                   (lambda _
                     (format #t (string-append
                                  "rule "
                                  "org.apache.maven.shared.utils.** "
                                  "org.apache.maven.surefire.shade.common."
                                  "org.apache.maven.shared.utils.@1~%"))))
                 (invoke "java" "-jar" jarjar "process" "rules" injar outjar)
                 (delete-file injar)
                 (rename-file outjar injar)))
             #t))
         (replace 'install
           (install-from-pom "surefire-providers/common-java5/pom.xml")))))
    (propagated-inputs
     `(("maven-shared-utils" ,maven-shared-utils-3.1)
       ("java-surefire-api" ,java-surefire-api)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-jarjar" ,java-jarjar)
       ("java-junit" ,java-junit)
       ("java-fest-assert" ,java-fest-assert)))
    (synopsis "Common java5 facilities for Maven SureFire")
    (description "This package contains shared Java 5 code for all providers.")))

(define-public java-surefire-common-junit3
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-common-junit3")
    (arguments
     `(#:jar-name "java-surefire-common-junit3.jar"
       #:source-dir "surefire-providers/common-junit3/src/main/java"
       #:test-dir "surefire-providers/common-junit3/src/test"
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "surefire-providers/common-junit3/pom.xml")))))
    (propagated-inputs
     `(("java-junit" ,java-junit)
       ("java-surefire-api" ,java-surefire-api)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-junit" ,java-junit)
       ("java-fest-assert" ,java-fest-assert)))
    (synopsis "Shared JUnit3 provider code for Maven SureFire")
    (description "This package contains shared code for all JUnit providers.")))

(define-public java-surefire-common-junit4
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-common-junit4")
    (arguments
     `(#:jar-name "java-surefire-common-junit4.jar"
       #:source-dir "surefire-providers/common-junit4/src/main/java"
       #:tests? #f; tests require junit 4.0
       #:phases
       (modify-phases %standard-phases
         (replace 'install
           (install-from-pom "surefire-providers/common-junit4/pom.xml")))))
    (propagated-inputs
     `(("java-junit" ,java-junit)
       ("java-surefire-api" ,java-surefire-api)
       ("java-surefire-common-java5" ,java-surefire-common-java5)
       ("java-surefire-common-junit3" ,java-surefire-common-junit3)
       ("maven-shared-utils" ,maven-shared-utils-3.1)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (synopsis "Shared JUnit4 provider code for Maven SureFire")
    (description "This package contains shared code for all JUnit providers,
starting from JUnit 4.")))

(define-public java-surefire-junit4
  (package
    (inherit java-surefire-logger-api)
    (name "java-surefire-junit4")
    (arguments
     `(;#:tests? #f
       #:jar-name "java-surefire-junit4.jar"
       #:source-dir "surefire-providers/surefire-junit4/src/main/java"
       #:test-dir "surefire-providers/surefire-junit4/src/test"
       #:modules ((guix build ant-build-system)
                  (guix build utils)
                  (guix build java-utils)
                  (sxml simple))
       #:phases
       (modify-phases %standard-phases
         (add-before 'install 'regenerate-own-pom
           (lambda _
             ;; Surefire struggles resolving artifacts because of this pom
             ;; file, resulting in a NullPointerException when collecting
             ;; Artifacts (and a "Failure detected." message from
             ;; DefaultArtifactResolver).  Replace the pom file with a much
             ;; simpler one.  Everything is shaded anyway (as used to be the
             ;; case in 2.22), so there will not be missing dependencies.
             (with-output-to-file "surefire-providers/surefire-junit4/pom.xml"
               (lambda _
                 (sxml->xml
                   `((project
                       (modelVersion "4.0.0")
                       (name "Surefire JUnit4")
                       (groupId "org.apache.maven.surefire")
                       (artifactId "surefire-junit4")
                       (version ,,(package-version java-surefire-common-java5)))))))
             #t))
         (add-before 'build 'copy-resources
           (lambda _
             (mkdir-p "build/classes")
             (copy-recursively "surefire-providers/surefire-junit4/src/main/resources"
                               "build/classes")
             #t))
         (add-before 'build 'prepare-shade
           (lambda* (#:key inputs #:allow-other-keys)
             (mkdir-p "build/classes")
             (with-directory-excursion "build/classes"
               (for-each
                 (lambda (input)
                   (for-each
                     (lambda (jar-file)
                       (invoke "jar" "xf" jar-file)
                       (delete-file-recursively "META-INF"))
                     (find-files (assoc-ref inputs input) ".*.jar$")))
                 '("maven-shared-utils" "java-surefire-common-java5"
                   "java-surefire-common-junit3" "java-surefire-common-junit4"
                   "java-surefire-api")))
             #t))
         (add-after 'build 'shade
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((jarjar
                   (car (find-files (assoc-ref inputs "java-jarjar") ".*.jar$")))
                   (injar "java-surefire-junit4.jar")
                   (outjar "java-surefire-junit4-shaded.jar"))
               (with-directory-excursion "build/jar"
                 (with-output-to-file "rules"
                   (lambda _
                     (format #t (string-append
                                  "rule "
                                  "org.apache.maven.shared.utils.** "
                                  "org.apache.maven.surefire.shade."
                                  "org.apache.maven.shared.utils.@1~%"))))
                 (invoke "java" "-jar" jarjar "process" "rules" injar outjar)
                 (delete-file injar)
                 (rename-file outjar injar)))
             #t))
         (replace 'install
           (install-from-pom "surefire-providers/surefire-junit4/pom.xml")))))
    (propagated-inputs
     `(("java-junit" ,java-junit)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (inputs
     `(("java-surefire-common-junit4" ,java-surefire-common-junit4)
       ("java-surefire-common-junit3" ,java-surefire-common-junit3)
       ("java-surefire-common-java5" ,java-surefire-common-java5)
       ("java-surefire-api" ,java-surefire-api)))
    (native-inputs
     `(("java-jarjar" ,java-jarjar)
       ("unzip" ,unzip)
       ("java-junit" ,java-junit)
       ("java-hamcrest-all" ,java-hamcrest-all)
       ("java-fest-assert" ,java-fest-assert)))
    (synopsis "SureFire JUnit 4.0+ runner")
    (description "This package contains the runner for tests run on a forked
JVM, using JUnit 4.0 or later.")))

(define-public maven-surefire-common
  (package
    (inherit java-surefire-logger-api)
    (name "maven-surefire-common")
    (arguments
     `(#:tests? #f; require mockito 2
       #:jar-name "maven-surefire-common.jar"
       #:source-dir "maven-surefire-common/src/main/java"
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'prepare-shade
           (lambda* (#:key inputs #:allow-other-keys)
             (mkdir-p "build/classes")
             (with-directory-excursion "build/classes"
               (for-each
                 (lambda (input)
                   (for-each
                     (lambda (jar-file)
                       (invoke "jar" "xf" jar-file)
                       (delete-file-recursively "META-INF"))
                     (find-files (assoc-ref inputs input) ".*.jar$")))
                 '("maven-shared-utils" "java-commons-io" "java-commons-lang3"
                   "java-commons-compress" "maven-common-artifact-filters")))
             #t))
         (add-after 'build 'shade
           (lambda* (#:key inputs #:allow-other-keys)
             (let ((jarjar
                   (car (find-files (assoc-ref inputs "java-jarjar") ".*.jar$")))
                   (injar "maven-surefire-common.jar")
                   (outjar "maven-surefire-common-shaded.jar"))
               (with-directory-excursion "build/jar"
                 (with-output-to-file "rules"
                   (lambda _
                     (format #t (string-append
                                  "rule "
                                  "org.apache.maven.shared.utils.** "
                                  "org.apache.maven.surefire.shade.common."
                                  "org.apache.maven.shared.utils.@1~%"))
                     (format #t (string-append
                                  "rule "
                                  "org.apache.commons.io.** "
                                  "org.apache.maven.surefire.shade.common."
                                  "org.apache.commons.io.@1~%"))
                     (format #t (string-append
                                  "rule "
                                  "org.apache.commons.lang3.** "
                                  "org.apache.maven.surefire.shade.common."
                                  "org.apache.commons.lang3.@1~%"))
                     (format #t (string-append
                                  "rule "
                                  "org.apache.commons.compress.** "
                                  "org.apache.maven.surefire.shade.common."
                                  "org.apache.commons.compress.@1~%"))))
                 (invoke "java" "-jar" jarjar "process" "rules" injar outjar)
                 (delete-file injar)
                 (rename-file outjar injar)))
             #t))
         (add-before 'install 'fix-pom
           (lambda _
             (substitute* "maven-surefire-common/pom.xml"
               (("maven-toolchain") "maven-core"))
             #t))
         (replace 'install
           (install-from-pom "maven-surefire-common/pom.xml")))))
    (propagated-inputs
     `(("java-surefire-api" ,java-surefire-api)
       ("java-surefire-extensions-api" ,java-surefire-extensions-api)
       ("java-surefire-booter" ,java-surefire-booter)
       ("maven-core" ,maven-core)
       ("maven-plugin-annotations" ,maven-plugin-annotations)
       ("maven-common-artifact-filters" ,maven-common-artifact-filters)
       ("maven-artifact-transfer" ,maven-artifact-transfer)
       ("java-plexus-java" ,java-plexus-java)
       ("java-jansi" ,java-jansi)
       ("java-commons-io" ,java-commons-io)
       ("java-commons-lang3" ,java-commons-lang3)
       ("java-commons-compress" ,java-commons-compress)
       ("maven-shared-utils" ,maven-shared-utils-3.1)
       ("java-surefire-parent-pom" ,java-surefire-parent-pom)))
    (inputs
     `(("java-jsr305" ,java-jsr305)))
    (native-inputs
     `(("unzip" ,unzip)
       ("java-jarjar" ,java-jarjar)))
    (synopsis "API used in Surefire and Failsafe MOJO")
    (description "This package contains an API used in SureFire and Failsafe
MOJO.")))

(define-public maven-surefire-plugin
  (package
    (inherit java-surefire-logger-api)
    (name "maven-surefire-plugin")
    (arguments
     `(#:jar-name "maven-surefire-plugin.jar"
       #:source-dir "maven-surefire-plugin/src/main/java"
       #:tests? #f; test depends on maven-plugin-test-harness
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-plugin.xml
           (generate-plugin.xml "maven-surefire-plugin/pom.xml"
             "surefire"
             "."
             (list
               (list
                 "maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java"
                 "maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java"))))
         (replace 'install
           (install-from-pom "maven-surefire-plugin/pom.xml")))))
    (propagated-inputs
     `(("maven-surefire-common" ,maven-surefire-common)
       ("maven-core" ,maven-core)))
    (native-inputs
     `(("maven-plugin-annotations" ,maven-plugin-annotations)
       ("unzip" ,unzip)))
    (synopsis "SureFire Maven plugin that runs tests.")
    (description "The Surefire Plugin is used during the test phase of the
build lifecycle to execute the unit tests of an application.  It generates
reports in two different file formats, plain text and xml.")))

(define-public maven-jar-plugin
  (package
    (name "maven-jar-plugin")
    (version "3.2.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                     (url "https://github.com/apache/maven-jar-plugin")
                     (commit (string-append "maven-jar-plugin-" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "04y2rlmcabmc55ljqlkgbb5xx94a59cz1dvrnpfj1vzz024pqkyg"))))
    (build-system ant-build-system)
    (arguments
     `(#:jar-name "maven-jar-plugin.jar"
       #:source-dir "src/main/java"
       #:tests? #f; test depends on maven-plugin-test-harness
       #:phases
       (modify-phases %standard-phases
         (add-before 'build 'generate-plugin.xml
           (generate-plugin.xml "pom.xml"
             "jar"
             "src/main/java/org/apache/maven/plugins/jar"
             (list
               (list "AbstractJarMojo.java" "JarMojo.java")
               (list "AbstractJarMojo.java" "TestJarMojo.java"))))
         (replace 'install
           (install-from-pom "pom.xml")))))
    (propagated-inputs
     `(("maven-archiver" ,maven-archiver)
       ("maven-artifact" ,maven-3.0-artifact)
       ("maven-core" ,maven-3.0-core)
       ("maven-plugin-api" ,maven-3.0-plugin-api)
       ("maven-file-management" ,maven-file-management)
       ("maven-shared-utils" ,maven-shared-utils)
       ("java-plexus-archiver" ,java-plexus-archiver)
       ("java-plexus-utils" ,java-plexus-utils)))
    (inputs
     `(("maven-plugin-annotations" ,maven-plugin-annotations)))
    (home-page "https://maven.apache.org/plugins/maven-jar-plugin")
    (synopsis "Jar builder plugin for Maven")
    (description "This plugin provides the capability to build jars.  If you
would like to sign jars please use the Maven Jarsigner Plugin instead.")
    (license license:asl2.0)))