This file is indexed.

/usr/share/doc/libmaven-bundle-plugin-java/apache-felix-maven-bundle-plugin-bnd.html is in libmaven-bundle-plugin-java-doc 2.3.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>


  
    <title>Apache Felix - Apache Felix Maven Bundle Plugin (BND)</title>
    <link rel="stylesheet" href="apache-felix-maven-bundle-plugin-bnd_files/site.css" type="text/css" media="all">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head><body>
    <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img alt="Apache Felix" src="apache-felix-maven-bundle-plugin-bnd_files/logo.png" border="0"></a></div><div class="header"><a href="http://www.apache.org/"><img alt="Apache" src="apache-felix-maven-bundle-plugin-bnd_files/apache.png" border="0"></a></div></div>
    <div class="menu">

    
    
    

    
    
    
    

    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
            
            

            
            
            
            

            
            
            
            

            &gt;
	<li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li>
	<li><a href="http://felix.apache.org/site/license.html" title="license">license</a></li>
	<li><a href="http://felix.apache.org/site/downloads.cgi" rel="nofollow">downloads</a></li>
	<li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li>
	<li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li>
	<li><a href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</a></li>
	<li><a href="http://www.apache.org/" rel="nofollow">asf</a></li>
	<li><a href="http://www.apache.org/foundation/sponsorship.html" rel="nofollow">sponsorship</a></li>
	<li><a href="http://www.apache.org/foundation/thanks.html" rel="nofollow">sponsors</a>
<!-- ApacheCon Ad -->
<iframe src="apache-felix-maven-bundle-plugin-bnd_files/button.html" style="border-width: 0pt; float: left;" scrolling="no" width="135" frameborder="0" height="135"></iframe>
<p style="height: 100px;">
<!-- ApacheCon Ad -->
&lt;

        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
        
    
    </p></li></div>
    <div class="main">
<h1><a name="ApacheFelixMavenBundlePlugin(BND)-BundlePluginforMaven"></a>Bundle Plugin for Maven</h1>

<p>This plugin for Maven 2 is based on the <a href="http://www.aqute.biz/Code/Bnd" rel="nofollow">BND</a>
tool from Peter Kriens. The way BND works is by treating your project
as a big collection of classes (e.g., project code, dependencies, and
the class path). The way you create a bundle with BND is to tell it the
content of the bundle's JAR file as a subset of the available classes.
This plugin wraps BND to make it work specifically with the Maven 2
project structure and to provide it with reasonable default behavior
for Maven 2 projects.</p>

<div class="panelMacro"><table class="infoMacro"><colgroup><col width="24"><col></colgroup><tbody><tr><td valign="top"><img src="apache-felix-maven-bundle-plugin-bnd_files/information.gif" alt="" align="absmiddle" border="0" width="16" height="16"></td><td>If you have questions about the maven-bundle-plugin please read the <a href="http://felix.apache.org/site/apache-felix-bundle-plugin-faq.html" rel="nofollow">FAQ</a> first. If you still have questions you can ask them on the <a href="http://felix.apache.org/site/mailinglists.html" rel="nofollow">Felix user list</a>.</td></tr></tbody></table></div>

<p><em>NOTE: test scoped dependencies are <b>not</b> included in the classpath seen by BND.</em></p>

<p>Since the 1.4.0 release, this plugin also aims to automate OBR (OSGi
Bundle Repository) management. It helps manage a local OBR for your
local Maven repository, and also supports remote OBRs for bundle
distribution. The plug-in automatically computes bundle capabilities
and requirements, using a combination of Bindex and Maven metadata.</p>

<p><a name="ApacheFelixMavenBundlePlugin(BND)-simpleexample"></a></p>

<h1><a name="ApacheFelixMavenBundlePlugin(BND)-SimpleExample"></a>Simple Example</h1>

<p>Rather than going straight to a detailed list of plugin features, we
will first look at a simple example of how to use the plugin to give an
immediate flavor. A detailed "<a href="#ApacheFelixMavenBundlePlugin%2528BND%2529-howto">how to</a>" will follow.</p>

<p>Assume that we have a simple bundle project that has a pubic API package an several implementation packages, such as:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>org.foo.myproject.api
org.foo.myproject.impl1
org.foo.myproject.impl2
...
</pre>
</div></div>

<p>If we also assume that we have a bundle activator in one of the implementation packages, then the <tt>&lt;plugins&gt;</tt> section of the POM file for this bundle project would look like this:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>...
&lt;plugins&gt;
  &lt;plugin&gt;
    &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
    &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
    &lt;extensions&gt;true&lt;/extensions&gt;
    &lt;configuration&gt;
      &lt;instructions&gt;
        &lt;Export-Package&gt;org.foo.myproject.api&lt;/Export-Package&gt;
        &lt;Private-Package&gt;org.foo.myproject.*&lt;/Private-Package&gt;
        &lt;Bundle-Activator&gt;org.foo.myproject.impl1.Activator&lt;/Bundle-Activator&gt;
      &lt;/instructions&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;
&lt;/plugins&gt;
...
</pre>
</div></div>

<p>The <tt>&lt;Export-Package&gt;</tt> and <tt>&lt;Private-Package&gt;</tt> instructions tell the plugin about the contents of the resulting bundle JAR file. The <tt>&lt;Export-Package&gt;</tt> instruction tells the plugin which of the available packages to copy into the bundle <b>and</b> export, while the <tt>&lt;Private-Package&gt;</tt> instruction indicates which of the available packages to copy into the bundle <b>but not</b>
export. If the two sets overlap, as they do in the case, then the
export takes precedence. Since we did not specify any values for any
other bundle manifest headers, they will assume default values which
are described <a href="#ApacheFelixMavenBundlePlugin%2528BND%2529-defaultbehavior">below</a>. One specific behavior to highlight is that the plugin generates the <tt>Import-Package</tt>
bundle manifest header based on the contents of the bundle, which means
that you generally do not ever need to explicitly specify it yourself.
That's it.</p>

<h1><a name="ApacheFelixMavenBundlePlugin(BND)-Features"></a>Features</h1>

<p>The BND library underlying the plugin defines instructions to direct
its behavior. For this Maven plugin, these instructions are issued in
the plugin configuration section of the POM file, as was illustrated <a href="#ApacheFelixMavenBundlePlugin%2528BND%2529-simpleexample">above</a>. BND recognizes three types of instructions:</p>

<ol>
	<li><em>Manifest headers</em> - Any instruction that starts with
a capital letter will appear in the resulting bundle's manifest file;
the value for the header will either be copied, augmented, or generated
by BND depending on the instruction.</li>
	<li><em>Variables</em> - Any instruction starting with a lowercase letter is assumed to be a variable in the form of a name-value pair, such as <tt>version=3.0</tt>, that can be used for property substitution, but is not copied to the manifest.</li>
	<li><em>Directives</em>
- Any instruction starting with a '-' character is considered to be a
directive that informs BND to perform some special processing and is
not copied to the manifest.</li>
</ol>


<p>The remainder of this section covers the most important aspects of BND's instructions; for complete details refer to the <a href="http://www.aqute.biz/Code/Bnd" rel="nofollow">BND documentation</a>.</p>

<p><a name="ApacheFelixMavenBundlePlugin(BND)-instructions"></a></p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Instructions"></a>Instructions</h2>

<h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{&lt;ExportPackage&gt;}}"></a><tt>&lt;Export-Package&gt;</tt></h3>

<p>The <tt>&lt;Export-Package&gt;</tt> instruction is a list of
packages for the bundle to export. These packages are copied into the
resulting bundle JAR file from the available classes (i.e., project
classes, dependencies, and class path); thus, it is possible to include
classes into your bundle that are not associated with source files in
your project. <tt>&lt;Export-Package&gt;</tt> can be specified with
package patterns using the '*' wildcard. Also, it is possible to
exclude packages using negation by starting the package pattern with
'!'. Thus, non-negated patterns indicate which of the available
packages to include in the bundle, whereas negated patterns indicate
which should not be included in the bundle.</p>

<p>The list of package patterns is ordered and earlier patterns are applied before later patterns. For example, if you specify "<tt>org.foo.*,!org.foo.impl</tt>" the second pattern has no effect since all <tt>org.foo</tt> packages have already been selected by the first pattern. Instead, you should specify "<tt>!org.foo.impl,org.foo.*</tt>", which will export all <tt>org.foo</tt> packages except <tt>org.foo.impl</tt>.</p>

<p>Following standard OSGi R4 syntax, package patterns can include both
directives and attributes, which will be copied appropriately into the
generated Export-Package manifest header. Besides explicitly listing
package version attributes, BND will also determine package versions by
examining the source JAR file or from <tt>packageinfo</tt> files in the package directory.</p>

<h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{&lt;PrivatePackage&gt;}}"></a><tt>&lt;Private-Package&gt;</tt></h3>

<p>The <tt>&lt;Private-Package&gt;</tt> instruction is similar in every way to the <tt>&lt;Export-Package&gt;</tt> instruction, except for the fact that these packages will <b>not</b>
be exported by the bundle. If a package is selected by both the export
and private package headers, then the export takes precedence.</p>

<h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{&lt;IncludeResource&gt;}}"></a><tt>&lt;Include-Resource&gt;</tt></h3>

<p>The <tt>&lt;Include-Resource&gt;</tt> instruction is a list of
arbitrary resources that should be copied into the bundle JAR file. The
specified resources are declared as clauses that can have the following
forms:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>clause ::= assignment | inline | simple
assignment ::= PATH '=' PATH
simple ::= PATH
inline ::= '@' PATH
</pre>
</div></div>

<p>For the <tt>&lt;Include-Resource&gt;</tt> instruction, actual file paths are relative to the <tt>pom.xml</tt>, while file copy destinations are relative to the root of the resulting bundle JAR file. In the case of <tt>assignment</tt> or <tt>simple</tt> forms, the <tt>PATH</tt> parameter can point to a file or directory. The <tt>simple</tt>
form will place the resource in the bundle JAR with only the file name,
i.e., without any path component. For example, including <tt>src/main/resources/a/b.c</tt> will result in a resource <tt>b.c</tt> in the root of the bundle JAR. If the <tt>PATH</tt>
points to a directory, the entire directory hierarchy is copied into
the resulting bundle JAR file relative to the specified directory. If a
specific resource must be placed into a subdirectory of the bundle jar,
then use the <tt>assignment</tt> form, where the first path is the the
destination path (including file name if the resource is a file) and
the second path is the resource to copy. The <tt>inline</tt> form requires a ZIP or JAR file, which will be completely expanded in the bundle JAR.</p>

<p>If a resource clause is specified inside of "{ ... }" brackets, then
variable substitution will be performed on the resource, where
variables in the resources are denoted with "${ ... }" syntax.</p>

<p>By default the bundle plugin converts the project's Maven resource directories into a single <tt>&lt;Include-Resource&gt;</tt> instruction. If you specify your own <tt>&lt;Include-Resource&gt;</tt> instruction, this will replace the generated one. To include the generated list of Maven resources in your own <tt>&lt;Include-Resource&gt;</tt> instruction just add {<tt>maven-resources</tt>} to the list and it will be expanded automatically.</p>

<h3><a name="ApacheFelixMavenBundlePlugin(BND)-{{&lt;ImportPackage&gt;}}"></a><tt>&lt;Import-Package&gt;</tt></h3>

<p>The <tt>&lt;Import-Package&gt;</tt> instruction is a list of
packages that are required by the bundle's contained packages. The
default for this header is "*", resulting in importing all referred
packages. This header rarely has to be explicitly specified. However,
in certain cases when there is an unwanted import, such an import can
be removed by using a negation package pattern. The package patterns
work in the same way as for <tt>&lt;Export-Package&gt;</tt>, which means they are ordered. For example, if you wanted to import all packages except <tt>org.foo.impl</tt> you would specify "<tt>!org.foo.impl,*</tt>"</p>

<p><a name="ApacheFelixMavenBundlePlugin(BND)-defaultbehavior"></a></p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-DefaultBehavior"></a>Default Behavior</h2>

<p>To use this plugin, very little information is required by BND. As
part of the Maven integration, the plugin tries to set reasonable
defaults for various instructions. For example:</p>

<ul>
	<li><tt>&lt;Bundle-SymbolicName&gt;</tt> is computed using the shared <a href="http://svn.apache.org/repos/asf/maven/shared/trunk/maven-osgi/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java" rel="nofollow">Maven2OsgiConverter</a> component, which uses the following algorithm:<br>
Get the symbolic name as groupId + "." + artifactId, with the following exceptions:
	<ul>
		<li>if
artifact.getFile is not null and the jar contains a OSGi Manifest with
Bundle-SymbolicName property then that value is returned</li>
		<li>if
groupId has only one section (no dots) and artifact.getFile is not null
then the first package name with classes is returned. eg.
commons-logging:commons-logging -&gt; org.apache.commons.logging</li>
		<li>if artifactId is equal to last section of groupId then groupId is returned. eg. org.apache.maven:maven -&gt; org.apache.maven</li>
		<li>if
artifactId starts with last section of groupId that portion is removed.
eg. org.apache.maven:maven-core -&gt; org.apache.maven.core<br>
The computed symbolic name is also stored in the <tt>$(maven-symbolicname)</tt> property in case you want to add attributes or directives to it.</li>
	</ul>
	</li>
	<li><tt>&lt;Export-Package&gt;</tt>
is now assumed to be the set of packages in your local Java sources,
excluding the default package '.' and any packages containing 'impl' or
'internal'.<br>
<em>(before version 2 of the bundleplugin it was based on the symbolic name)</em></li>
	<li><tt>&lt;Private-Package&gt;</tt> is now assumed to be the set of packages in your local Java sources (note that any packages in both <tt>&lt;Export-Package&gt;</tt> and <tt>&lt;Private-Package&gt;</tt> will be exported).<br>
<em>(before version 2 of the bundleplugin it was assumed to be empty by default)</em></li>
	<li><tt>&lt;Import-Package&gt;</tt> is assumed to be "<tt>*</tt>", which imports everything referred to by the bundle content, but not contained in the bundle.<br>
<em>Any exported packages are also imported by default, to ensure a consistent class space.</em></li>
	<li><tt>&lt;Include-Resource&gt;</tt> is generated from the project's Maven resources, typically "<tt>src/main/resources/</tt>",
which will copy the specified project directory hierarchy into the
resulting bundle JAR file, mirroring standard Maven behavior.</li>
	<li><tt>&lt;Bundle-Version&gt;</tt> is assumed to be "<tt>${pom.version</tt>}" but is normalized to the OSGi version format of "<tt>MAJOR.MINOR.MICRO.QUALIFIER</tt>", for example "<tt>2.1-SNAPSHOT</tt>" would become "<tt>2.1.0.SNAPSHOT</tt>".</li>
	<li><tt>&lt;Bundle-Name&gt;</tt> is assumed to be "<tt>${pom.name</tt>}".</li>
	<li><tt>&lt;Bundle-Description&gt;</tt> is assumed to be "<tt>${pom.description</tt>}".</li>
	<li><tt>&lt;Bundle-License&gt;</tt> is assumed to be "<tt>${pom.licenses</tt>}".</li>
	<li><tt>&lt;Bundle-Vendor&gt;</tt> is assumed to be "<tt>${pom.organization.name</tt>}".</li>
	<li><tt>&lt;Bundle-DocURL&gt;</tt> is assumed to be "<tt>${pom.organization.url</tt>}".</li>
</ul>


<p>Since the plugin creates bundles for OSGi R4, it hard-codes <tt>Bundle-ManifestVersion</tt>
to be '2'. Additionally, it generates imports for every export to
ensure package substitutability, which is very important when working
with collaborating services. It is possible to override any of these
values (except <tt>Bundle-ManifestVersion</tt>) just by specifying the desired value in the plugin configuration section of the POM file.</p>

<p><a name="ApacheFelixMavenBundlePlugin(BND)-howto"></a></p>

<h1><a name="ApacheFelixMavenBundlePlugin(BND)-Detailed&quot;HowTo&quot;"></a>Detailed "How To"</h1>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-GetMaven2"></a>Get Maven2</h2>

<p>The first step in the process of using the plugin is downloading and
installing the latest version of the Maven2 runtime. The latest Maven2
release and instuctions for getting started with Maven2 can be found at
the <a href="http://maven.apache.org/index.html" rel="nofollow">Maven website</a>.</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-UsingthePlugin"></a>Using the Plugin</h2>

<p>To use the maven-bundle-plugin, you first need to add the plugin and
some appropriate plugin configuration to your bundle project's POM.
Below is an example of a simple OSGi bundle POM for Maven2:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>&lt;project&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;my-osgi-bundles&lt;/groupId&gt;
  &lt;artifactId&gt;examplebundle&lt;/artifactId&gt;
  &lt;packaging&gt;bundle&lt;/packaging&gt;    &lt;!-- (1) --&gt;
  &lt;version&gt;1.0&lt;/version&gt;
  &lt;name&gt;Example Bundle&lt;/name&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
      &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
      &lt;version&gt;1.0.0&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;    &lt;!-- (2) START --&gt;
        &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
        &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
        &lt;configuration&gt;
          &lt;instructions&gt;
            &lt;Export-Package&gt;com.my.company.api&lt;/Export-Package&gt;
            &lt;Private-Package&gt;com.my.company.*&lt;/Private-Package&gt;
            &lt;Bundle-Activator&gt;com.my.company.Activator&lt;/Bundle-Activator&gt;
          &lt;/instructions&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;    &lt;!-- (2) END --&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
</div></div>

<p>There are two main things to note: (1) the <tt>&lt;packaging&gt;</tt>
specifier must be "bundle" and (2) the plugin and configuration must be
specified (the configuration section is where you will issue
instructions to the plugin).</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-RealWorldExample"></a>Real-World Example</h2>

<p>Consider this more real-world example using Felix' Log Service
implementation. The Log Service project is comprised of a single
package: <tt>org.apache.felix.log.impl</tt>. It has a dependency on
the core OSGi interfaces as well as a dependency on the compendium OSGi
interfaces for the specific log service interfaces. The following is
its POM file:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>&lt;project&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
  &lt;artifactId&gt;org.apache.felix.log&lt;/artifactId&gt;
  &lt;packaging&gt;bundle&lt;/packaging&gt;
  &lt;name&gt;Apache Felix Log Service&lt;/name&gt;
  &lt;version&gt;0.8.0-SNAPSHOT&lt;/version&gt;
  &lt;description&gt;
    This bundle provides an implementation of the OSGi R4 Log service.
  &lt;/description&gt;
  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
      &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
      &lt;version&gt;0.8.0-incubator&lt;/version&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
      &lt;artifactId&gt;org.osgi.compendium&lt;/artifactId&gt;
      &lt;version&gt;0.9.0-incubator-SNAPSHOT&lt;/version&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
        &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
        &lt;configuration&gt;
          &lt;instructions&gt;
            &lt;Export-Package&gt;org.osgi.service.log&lt;/Export-Package&gt;
            &lt;Private-Package&gt;org.apache.felix.log.impl&lt;/Private-Package&gt;
            &lt;Bundle-SymbolicName&gt;${pom.artifactId}&lt;/Bundle-SymbolicName&gt;
            &lt;Bundle-Activator&gt;${pom.artifactId}.impl.Activator&lt;/Bundle-Activator&gt;
            &lt;Export-Service&gt;org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService&lt;/Export-Service&gt;
          &lt;/instructions&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;
</pre>
</div></div>

<p>Notice that the <tt>&lt;Export-Package&gt;</tt> instruction
specifies that the bundle exports the Log Service package, even though
this package is not contained in the bundle project. By declaring this,
the plugin will copy the Log Service package into the resulting bundle
JAR file. This is useful in this case because now the bundle can
resolve without having to download the entire compendium bundle. The
resulting manifest for the Log Service bundle looks like this (notice
how the imports/exports automatically have version information
associated with them, which was obtained from packageinfo files in the
source packages):</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>Manifest-Version: 1
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Activator: org.apache.felix.log.impl.Activator
Import-Package: org.osgi.framework;version=1.3, org.osgi.service.log;v
 ersion=1.3
Include-Resource: src/main/resources
Export-Package: org.osgi.service.log;uses:=org.osgi.framework;version=
 1.3
Bundle-Version: 0.8.0.SNAPSHOT
Bundle-Name: Apache Felix Log Service
Bundle-Description: This bundle provides an implementation of the OSGi
  R4 Log service.
Private-Package: org.apache.felix.log.impl
Bundle-ManifestVersion: 2
Export-Service: org.osgi.service.log.LogService,org.osgi.service.log.L
 ogReaderService
Bundle-SymbolicName: org.apache.felix.log
</pre>
</div></div>

<p>The resulting bundle JAR file has the following content (notice how
the LICENSE and NOTICE files were automatically copied from the <tt>src/main/resources/</tt> directory of the project):</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>META-INF/MANIFEST.MF
LICENSE
META-INF/
META-INF/maven/
META-INF/maven/org.apache.felix/
META-INF/maven/org.apache.felix/org.apache.felix.log/
META-INF/maven/org.apache.felix/org.apache.felix.log/pom.properties
META-INF/maven/org.apache.felix/org.apache.felix.log/pom.xml
NOTICE
org/
org/apache/
org/apache/felix/
org/apache/felix/log/
org/apache/felix/log/impl/
org/apache/felix/log/impl/Activator.class
org/apache/felix/log/impl/Log.class
org/apache/felix/log/impl/LogEntryImpl.class
org/apache/felix/log/impl/LogException.class
org/apache/felix/log/impl/LogListenerThread.class
org/apache/felix/log/impl/LogNode.class
org/apache/felix/log/impl/LogNodeEnumeration.class
org/apache/felix/log/impl/LogReaderServiceFactory.class
org/apache/felix/log/impl/LogReaderServiceImpl.class
org/apache/felix/log/impl/LogServiceFactory.class
org/apache/felix/log/impl/LogServiceImpl.class
org/osgi/
org/osgi/service/
org/osgi/service/log/
org/osgi/service/log/LogEntry.class
org/osgi/service/log/LogListener.class
org/osgi/service/log/LogReaderService.class
org/osgi/service/log/LogService.class
org/osgi/service/log/package.html
org/osgi/service/log/packageinfo
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype"></a>Adding OSGi metadata to existing projects without changing the packaging type</h2>

<p>If you want to keep your project packaging type (for example "jar") but would like to add OSGi metadata<br>
you can use the manifest goal to generate a bundle manifest. The maven-jar-plugin can then be used to<br>
add this manifest to the final artifact. For example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;plugin&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>maven-jar-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;configuration&gt;</span>
    <span class="code-tag">&lt;archive&gt;</span>  
      <span class="code-tag">&lt;manifestFile&gt;</span>${project.build.outputDirectory}/META-INF/MANIFEST.MF<span class="code-tag">&lt;/manifestFile&gt;</span>
    <span class="code-tag">&lt;/archive&gt;</span> 
  <span class="code-tag">&lt;/configuration&gt;</span>
<span class="code-tag">&lt;/plugin&gt;</span>  
<span class="code-tag">&lt;plugin&gt;</span>   
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;executions&gt;</span>
    <span class="code-tag">&lt;execution&gt;</span>
      <span class="code-tag">&lt;id&gt;</span>bundle-manifest<span class="code-tag">&lt;/id&gt;</span>
      <span class="code-tag">&lt;phase&gt;</span>process-classes<span class="code-tag">&lt;/phase&gt;</span>
      <span class="code-tag">&lt;goals&gt;</span>    
        <span class="code-tag">&lt;goal&gt;</span>manifest<span class="code-tag">&lt;/goal&gt;</span>
      <span class="code-tag">&lt;/goals&gt;</span>   
    <span class="code-tag">&lt;/execution&gt;</span>
  <span class="code-tag">&lt;/executions&gt;</span>
<span class="code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>

<p>If you want to use packaging types other than "jar" and "bundle" then you also need to enable support<br>
for them in the bundleplugin configuration, for example if you want to use the plugin with WAR files:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;plugin&gt;</span>
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;executions&gt;</span>
    <span class="code-tag">&lt;execution&gt;</span>
      <span class="code-tag">&lt;id&gt;</span>bundle-manifest<span class="code-tag">&lt;/id&gt;</span>
      <span class="code-tag">&lt;phase&gt;</span>process-classes<span class="code-tag">&lt;/phase&gt;</span>
      <span class="code-tag">&lt;goals&gt;</span>
        <span class="code-tag">&lt;goal&gt;</span>manifest<span class="code-tag">&lt;/goal&gt;</span>
      <span class="code-tag">&lt;/goals&gt;</span>
    <span class="code-tag">&lt;/execution&gt;</span>
  <span class="code-tag">&lt;/executions&gt;</span>
  <span class="code-tag">&lt;configuration&gt;</span>
    <span class="code-tag">&lt;supportedProjectTypes&gt;</span>
      <span class="code-tag">&lt;supportedProjectType&gt;</span>jar<span class="code-tag">&lt;/supportedProjectType&gt;</span>
      <span class="code-tag">&lt;supportedProjectType&gt;</span>bundle<span class="code-tag">&lt;/supportedProjectType&gt;</span>
      <span class="code-tag">&lt;supportedProjectType&gt;</span>war<span class="code-tag">&lt;/supportedProjectType&gt;</span>
    <span class="code-tag">&lt;/supportedProjectTypes&gt;</span>
    <span class="code-tag">&lt;instructions&gt;</span>
      <span class="code-tag"><span class="code-comment">&lt;!-- ...etc... --&gt;</span></span>
    <span class="code-tag">&lt;/instructions&gt;</span>
  <span class="code-tag">&lt;/configuration&gt;</span>
<span class="code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-BuildingthePlugin"></a>Building the Plugin</h2>

<p>The plugin is hosted at the Apache Felix project. The following
steps describe how to build and install the plugin into your local
Maven2 repository.</p>

<p>Using the SVN client of your choice, checkout the maven-bundle-plugin project.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>$ svn co http://svn.apache.org/repos/asf/felix/trunk/bundleplugin
</pre>
</div></div>

<p>Using Maven2, build and install the maven-bundle-plugin by issuing
the following Maven2 command in the project directory that was created
as a result of the previous step.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>$ mvn install
</pre>
</div></div>

<h1><a name="ApacheFelixMavenBundlePlugin(BND)-Goals"></a>Goals</h1>

<p>The maven-bundle-plugin also provides additional functionality via
some Maven goals. Command-line execution of a goal is performed as
follows:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>mvn org.apache.felix:maven-bundle-plugin:GOAL
</pre>
</div></div>

<p>Where GOAL is one of the following:</p>

<ul>
	<li><b><tt>bundle</tt></b> - build an OSGi bundle jar for the current project<br>
configuration options:
	<ul>
		<li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li>
		<li><em><tt>unpackBundle</tt></em> unpack bundle contents to output directory, defaults to false</li>
		<li><em><tt>excludeDependencies</tt></em> comma-separated list of dependency artifactIds to exclude from the classpath passed to Bnd, use "true" to exclude everything.<br>
Version 2 of the bundleplugin now supports the same style of filter clauses in <tt>excludeDependencies</tt> as <tt>Embed-Dependency</tt>.</li>
		<li><em><tt>classifier</tt></em> attach bundle to the project using the given classifier</li>
		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>bundleall</tt></b> - build OSGi bundle jars for all transitive dependencies<br>
configuration options:
	<ul>
		<li><em><tt>wrapImportPackage</tt></em> defaults to "*"</li>
		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>wrap</tt></b> - as above, but limited to the first level of dependencies<br>
configuration options:
	<ul>
		<li><em><tt>wrapImportPackage</tt></em> defaults to "*"</li>
		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>manifest</tt></b> - create an OSGi manifest for the current project<br>
configuration options:
	<ul>
		<li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li>
		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>install</tt></b> - adds the current bundle project to the local OBR<br>
configuration options:
	<ul>
		<li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
	</ul>
	</li>
</ul>


<p>More GOALs are available in the <b>1.4.0</b> release:</p>

<ul>
	<li><b><tt>ant</tt></b> - create an Ant build script to rebuild the bundle</li>
</ul>


<ul>
	<li><b><tt>install-file</tt></b> - adds a local bundle file to the local OBR<br>
configuration options:
	<ul>
		<li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
		<li><em><tt>groupId</tt></em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>artifactId</tt></em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>version</tt></em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>packaging</tt></em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>classifier</tt></em> Maven classifier type, defaults to none</li>
		<li><em><tt>pomFile</tt></em> optional Pom file describing the bundle</li>
		<li><em><tt>file</tt></em> bundle file, defaults to the bundle from the local Maven repository</li>
		<li><em><tt>obrXml</tt></em> optional additional properties for the bundle</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>deploy</tt></b> - adds the current bundle project to a remote OBR<br>
configuration options:
	<ul>
		<li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to NONE (which means no remote OBR deployment)</li>
		<li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
		<li><em><tt>prefixUrl</tt></em> optional public URL prefix for the remote repository</li>
		<li><em><tt>bundleUrl</tt></em> optional public URL where the bundle has been deployed</li>
		<li><em><tt>altDeploymentRepository</tt></em> alternative remote repository, <em>id::layout::url</em></li>
		<li><em><tt>obrDeploymentRepository</tt></em> optional OBR specific deployment repository.</li>
		<li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li>
		<li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>deploy-file</tt></b> - adds a local bundle file to a remote OBR<br>
configuration options:
	<ul>
		<li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to an empty string</li>
		<li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
		<li><em><tt>repositoryId</tt></em> optional repository id, used to lookup authentication settings</li>
		<li><em><tt>url</tt></em> remote repository transport URL, like
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>scpexe://host/path/to/obr
</pre>
</div></div></li>
		<li><em><tt>bundleUrl</tt></em> public URL of deployed bundle, like
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>http://www.foo.org/bundles/foo.jar
</pre>
</div></div></li>
		<li><em><tt>groupId</tt></em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>artifactId</tt></em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>version</tt></em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>packaging</tt></em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
		<li><em><tt>classifier</tt></em> Maven classifier type, defaults to none</li>
		<li><em><tt>pomFile</tt></em> optional Pom file describing the bundle</li>
		<li><em><tt>file</tt></em> bundle file, defaults to the bundle from the local Maven repository</li>
		<li><em><tt>obrXml</tt></em> optional additional properties for the bundle</li>
		<li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>clean</tt></b> - cleans the local OBR, removing missing bundles<br>
configuration options:
	<ul>
		<li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
	</ul>
	</li>
</ul>


<ul>
	<li><b><tt>remote-clean</tt></b> - cleans a remote OBR, removing missing bundles<br>
configuration options:
	<ul>
		<li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to NONE (which means no remote cleaning)</li>
		<li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
		<li><em><tt>prefixUrl</tt></em> optional public URL prefix for the remote repository</li>
		<li><em><tt>altDeploymentRepository</tt></em> alternative remote repository, <em>id::layout::url</em></li>
		<li><em><tt>obrDeploymentRepository</tt></em> optional OBR specific deployment repository.</li>
		<li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li>
	</ul>
	</li>
</ul>


<p>There are also new instructions available from the underlying BND
tool, which continues to be improved independently; for the latest see <a href="http://aqute.biz/Code/Bnd" rel="nofollow">BND documentation</a>.</p>

<p>The default goal <b><tt>bundle</tt></b> will be initialized by setting the &lt;packaging&gt; entry to "bundle".</p>

<h1><a name="ApacheFelixMavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailablefromversion1.2.0onwards"></a>The following features are only available from version 1.2.0 onwards</h1>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Embeddingdependencies"></a>Embedding dependencies</h2>

<p>The Maven Bundle Plugin supports embedding of selected project dependencies inside the bundle by using the <tt>&lt;Embed-Dependency&gt;</tt> instruction:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;Embed-Dependency&gt;</span>dependencies<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
</pre>
</div></div>

<p>where:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>dependencies ::= clause ( ',' clause ) *
clause ::= MATCH ( ';' attr '=' MATCH | ';inline=' inline )
attr ::= 'groupId' | 'artifactId' | 'version' | 'scope' | 'type' | 'classifier' | 'optional'
inline ::= 'true' | 'false' | PATH ( '|' PATH ) *
MATCH ::= &lt;globbed regular expression&gt;
PATH ::= &lt;Ant-style path expression&gt;
</pre>
</div></div>

<p>The plugin uses the <tt>&lt;Embed-Dependency&gt;</tt> instruction to transform the project dependencies into <tt>&lt;Include-Resource&gt;</tt> and <tt>&lt;Bundle-ClassPath&gt;</tt>
clauses, which are then appended to the current set of instructions and
passed onto BND. If you want the embedded dependencies to be at the
start or middle of <tt>&lt;Include-Resource&gt;</tt> or <tt>&lt;Bundle-ClassPath&gt;</tt> then you can use {<tt>maven-dependencies</tt>}, which will automatically expand to the relevant clauses.</p>

<p>The MATCH section accepts alternatives, separated by <b>|</b>, and can be negated by using <b>!</b> at the <em>beginning</em> of the MATCH. Use <b>*</b> to represent zero or more unknown characters and <b>?</b> to represent a single unknown character. There is no need to escape the <b>.</b> character inside MATCH. The first MATCH in a clause will filter against the artifactId.</p>

<p>some examples:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag"><span class="code-comment">&lt;!-- embed all compile and runtime scope dependencies --&gt;</span></span>
<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=compile|runtime<span class="code-tag">&lt;/Embed-Dependency&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- embed any dependencies with artifactId junit and scope runtime --&gt;</span></span>
<span class="code-tag">&lt;Embed-Dependency&gt;</span>junit;scope=runtime<span class="code-tag">&lt;/Embed-Dependency&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- inline all non-pom dependencies, except those with scope runtime --&gt;</span></span>
<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=!runtime;type=!pom;inline=true<span class="code-tag">&lt;/Embed-Dependency&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- embed all compile and runtime scope dependencies, except those with artifactIds in the given list --&gt;</span></span>
<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=compile|runtime;inline=false;artifactId=!cli|lang|runtime|tidy|jsch<span class="code-tag">&lt;/Embed-Dependency&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- inline contents of selected folders from all dependencies --&gt;</span></span>
<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;inline=images/**|icons/**<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
</pre>
</div></div>

<p>examples of using {<tt>maven-dependencies</tt>}:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;Include-Resource&gt;</span>
  {maven-resources}, {maven-dependencies},
  org/foo/Example.class=target/classes/org/foo/Example.class
<span class="code-tag">&lt;/Include-Resource&gt;</span>

<span class="code-tag">&lt;Bundle-ClassPath&gt;</span>.,{maven-dependencies},some.jar<span class="code-tag">&lt;/Bundle-ClassPath&gt;</span>
</pre>
</div></div>

<p>By default matched dependencies are embedded in the bundle as <tt>artifactId-version.jar</tt>. This behaviour can be modified using the following instructions:</p>

<ul>
	<li><tt>&lt;Embed-StripVersion&gt;true&lt;/Embed-StripVersion&gt;</tt> - removes the version from the file (ie. <em>artifactId.jar</em>)</li>
	<li><tt>&lt;Embed-StripGroup&gt;false&lt;/Embed-StripGroup&gt;</tt> - adds the groupId as a subdirectory (ie. <em>groupId/artifactId-version.jar</em>)</li>
	<li><tt>&lt;Embed-Directory&gt;directory&lt;/Embed-Directory&gt;</tt> - adds a subdirectory (ie. <em>directory/artifactId-version.jar</em>)</li>
</ul>


<p>Normally the plugin only checks direct dependencies, but this can be
changed to include the complete set of transitive dependencies with the
following option:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;Embed-Transitive&gt;</span>true<span class="code-tag">&lt;/Embed-Transitive&gt;</span>
</pre>
</div></div>

<p>If you want a dependency inlined instead of embedded add the <tt>inline=true</tt>. For example to inline all <em>compile</em> and <em>runtime</em> scoped dependencies use:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=compile|runtime;inline=true<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
</pre>
</div></div>

<h3><a name="ApacheFelixMavenBundlePlugin(BND)-EmbedDependencyandExportPackage"></a>Embed-Dependency and Export-Package</h3>

<p>If you embed a dependency with <tt>&lt;Embed-Dependency&gt;</tt>, and your <tt>&lt;Export-Package&gt;</tt> or <tt>&lt;Private-Package&gt;</tt> instructions match packages inside the embedded jar, you will see some duplication inside the bundle. This is because the <tt>&lt;Export-Package&gt;</tt> and <tt>&lt;Private-Package&gt;</tt>
instructions will result in classes being inlined in the bundle, even
though they also exist inside the embedded jar. If you want to export
packages from an embedded dependency without such duplication then you
can either inline the dependency, or use a new BND instruction called <tt>&lt;_exportcontents&gt;</tt>.</p>

<p><tt>&lt;_exportcontents&gt;</tt> behaves just like Export-Package, except it doesn't change the content of the bundle, just what content should be exported.</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-OBRintegration"></a>OBR integration</h2>

<p>The latest Maven Bundle Plugin automatically updates the local OBR
repository.xml file during the install phase, using a default location
of:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">&lt;LOCAL-MAVEN-REPOSITORY&gt;/repository.xml
</pre>
</div></div>

<p>You can configure the location of the OBR repository by using the command line:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">mvn clean install -DobrRepository=&lt;PATH_TO_OBR&gt;
</pre>
</div></div>

<p>or in the configuration section for the maven-bundle-plugin in your Maven POM:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
<span class="code-tag">&lt;configuration&gt;</span>
  <span class="code-tag">&lt;obrRepository&gt;</span>PATH_TO_OBR<span class="code-tag">&lt;/obrRepository&gt;</span>
  <span class="code-tag">&lt;instructions&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
  <span class="code-tag">&lt;/instructions&gt;</span>
<span class="code-tag">&lt;/configuration&gt;</span>
</pre>
</div></div>

<p>to disable OBR installation set the obrRepository to NONE, for example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
<span class="code-tag">&lt;configuration&gt;</span>
  <span class="code-tag">&lt;obrRepository&gt;</span>NONE<span class="code-tag">&lt;/obrRepository&gt;</span>
  <span class="code-tag">&lt;instructions&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
  <span class="code-tag">&lt;/instructions&gt;</span>
<span class="code-tag">&lt;/configuration&gt;</span>
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Eclipse/PDEintegration"></a>Eclipse/PDE integration</h2>

<p>It is possible to configure the Maven Bundle Plugin to put the
bundle manifest where Eclipse/PDE expects it, and use the Maven
Dependency Plugin to arrange for any embedded dependencies to appear in
a local directory that matches the Bundle-ClassPath entries. Here is an
example POM that does this:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>&lt;project&gt;

  &lt;properties&gt;
    &lt;bundle.symbolicName&gt;org.example&lt;/bundle.symbolicName&gt;
    &lt;bundle.namespace&gt;org.example&lt;/bundle.namespace&gt;
  &lt;/properties&gt;

  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;examples&lt;/groupId&gt;
  &lt;artifactId&gt;org.example&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;

  &lt;name&gt;${bundle.symbolicName} [${bundle.namespace}]&lt;/name&gt;

  &lt;packaging&gt;bundle&lt;/packaging&gt;

  &lt;build&gt;
    &lt;resources&gt;
      &lt;resource&gt;
        &lt;directory&gt;src/main/resources&lt;/directory&gt;
      &lt;/resource&gt;
      &lt;resource&gt;
        &lt;directory&gt;.&lt;/directory&gt;
        &lt;includes&gt;
          &lt;include&gt;plugin.xml&lt;/include&gt;
        &lt;/includes&gt;
      &lt;/resource&gt;
    &lt;/resources&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
        &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
        &lt;version&gt;1.2.1&lt;/version&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
        &lt;!--
          the following instructions build a simple set of public/private classes into an OSGi bundle
        --&gt;
        &lt;configuration&gt;
          &lt;manifestLocation&gt;META-INF&lt;/manifestLocation&gt;
          &lt;instructions&gt;
            &lt;Bundle-SymbolicName&gt;${bundle.symbolicName}&lt;/Bundle-SymbolicName&gt;
            &lt;Bundle-Version&gt;${pom.version}&lt;/Bundle-Version&gt;
            &lt;!--
              assume public classes are in the top package, and private classes are under ".internal"
            --&gt;
            &lt;Export-Package&gt;!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${pom.version}"&lt;/Export-Package&gt;
            &lt;Private-Package&gt;${bundle.namespace}.internal.*&lt;/Private-Package&gt;
            &lt;Bundle-Activator&gt;${bundle.namespace}.internal.ExampleActivator&lt;/Bundle-Activator&gt;
            &lt;!--
              embed compile/runtime dependencies using path that matches the copied dependency folder
            --&gt;
            &lt;Embed-Dependency&gt;*;scope=compile|runtime;inline=false&lt;/Embed-Dependency&gt;
            &lt;Embed-Directory&gt;target/dependency&lt;/Embed-Directory&gt;
            &lt;Embed-StripGroup&gt;true&lt;/Embed-StripGroup&gt;
          &lt;/instructions&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;id&gt;copy-dependencies&lt;/id&gt;
            &lt;phase&gt;package&lt;/phase&gt;
            &lt;goals&gt;
              &lt;goal&gt;copy-dependencies&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;

  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.osgi&lt;/groupId&gt;
      &lt;artifactId&gt;osgi_R4_core&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
      &lt;optional&gt;true&lt;/optional&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.osgi&lt;/groupId&gt;
      &lt;artifactId&gt;osgi_R4_compendium&lt;/artifactId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
      &lt;optional&gt;true&lt;/optional&gt;
    &lt;/dependency&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;junit&lt;/groupId&gt;
      &lt;artifactId&gt;junit&lt;/artifactId&gt;
      &lt;version&gt;3.8.1&lt;/version&gt;
      &lt;scope&gt;compile&lt;/scope&gt;
      &lt;optional&gt;true&lt;/optional&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

&lt;/project&gt;
</pre>
</div></div>

<p>To generate the Eclipse metadata use:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">mvn clean <span class="code-keyword">package</span> eclipse:eclipse -Declipse.pde install
</pre>
</div></div>

<p>and you should now be able to import this as an existing Eclipse project.</p>

<p>FYI: the above POM was generated using the <tt>pax-create-bundle</tt> command from <a href="http://www.ops4j.org/projects/pax/construct/index.html" rel="nofollow">Pax-Construct</a> and then tweaked to demonstrate using the Maven Dependency Plugin to handle embedded jars in Eclipse.</p>

<p>With the original Pax-Construct generated POM you would simply use:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">mvn clean <span class="code-keyword">package</span> pax:eclipse
</pre>
</div></div>

<p>to create the appropriate Eclipse files and manifest, and also
handle any embedded entries. The pax:eclipse goal extends
eclipse:eclipse, and supports the same parameters.</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Unpackingbundlecontentsto'target/classes'"></a>Unpacking bundle contents to 'target/classes'</h2>

<p>Once in a while you may create a bundle which contains additional classes to the ones compiled from <tt>src/main/java</tt>,
for example when you embed the classes from another jar. This can
sometimes cause unforeseen problems in Maven, as it will use the output
directory (<tt>target/classes</tt>) rather than the final bundle, when compiling against projects in the same reactor (ie. the same build).</p>

<p>The easiest way to get around this Maven 'feature' is to unpack the
contents of the bundle to the output directory after the packaging
step, so the additional classes will be found where Maven expects them.
Thankfully there is now an easy option to do this in the bundle-plugin:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
<span class="code-tag">&lt;configuration&gt;</span>
  <span class="code-tag">&lt;unpackBundle&gt;</span>true<span class="code-tag">&lt;/unpackBundle&gt;</span>
  <span class="code-tag">&lt;instructions&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
  <span class="code-tag">&lt;/instructions&gt;</span>
<span class="code-tag">&lt;/configuration&gt;</span>
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-UsinganexistingMANIFEST.MFfile"></a>Using an existing MANIFEST.MF file</h2>

<p>If you have an existing manifest, you can add this to the Bnd instructions, like so:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;_include&gt;</span>src/main/resources/META-INF/MANIFEST.MF<span class="code-tag">&lt;/_include&gt;</span>
<span class="code-tag">&lt;Export-Package&gt;</span>org.example.*<span class="code-tag">&lt;/Export-Package&gt;</span>
</pre>
</div></div>

<p>Bnd will use it when calculating the bundle contents, and will also
copy across all manifest attributes starting with a capital letter.<br>
As shown in the above example, you could use this to include a non-OSGi
manifest which you then customize with extra OSGi attributes.</p>

<h1><a name="ApacheFelixMavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailablefromversion1.4.0onwards"></a>The following features are only available from version 1.4.0 onwards</h1>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:ant"></a>bundle:ant</h2>

<p>The <b>ant</b> goal creates a customized <tt>build.xml</tt> Ant script along with a collection of BND instructions and properties, taken from the current project and stored in <tt>maven-build.bnd</tt>. You also need to run <b><tt>ant:ant</tt></b> to create the standard Ant support tasks to download Maven dependencies and perform compilation, etc.</p>

<p>The customized Ant script uses the BND tool to rebuild the bundle,
so any source changes should be reflected in the (re)generated manifest.</p>

<p>Example:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>mvn ant:ant bundle:ant

ant clean package
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:installfile"></a>bundle:install-file</h2>

<p>The <b>install-file</b> goal updates the local OBR with the details of a bundle from the local filesystem.</p>

<p>configuration:</p>
<ul>
	<li><em>obrRepository</em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
	<li><em>groupId</em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>artifactId</em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>version</em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>packaging</em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>classifier</em> Maven classifier type, defaults to none</li>
	<li><em>pomFile</em> optional Pom file describing the bundle</li>
	<li><em>file</em> bundle file, defaults to the bundle from the local Maven repository</li>
	<li><em>obrXml</em> optional additional properties for the bundle</li>
</ul>


<p>Example:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>mvn org.apache.felix:maven-bundle-plugin:1.4.0:install-file \
  -DpomFile=myPom.xml -Dfile=foo-1.0.jar
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:deploy"></a>bundle:deploy</h2>

<p>The <b>deploy goal</b> updates the remote OBR with the details of
the deployed bundle from the local Maven repository. The remote OBR is
found by querying the <tt>&lt;distributionManagement&gt;</tt> section of the project, unless <tt>-DaltDeploymentRepository</tt> is set. See <a href="http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html" rel="nofollow">http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html</a> for more details about these particular settings.</p>

<p>(If the project has an <tt>obr.xml</tt> file somewhere in its resources, then it will be automatically detected and applied.)</p>

<p>configuration:</p>
<ul>
	<li><em>remoteOBR</em> name of remote OBR, defaults to NONE (which means no remote OBR deployment)</li>
	<li><em>obrRepository</em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
	<li><em>altDeploymentRepository</em> alternative remote repository, <em>id::layout::url</em></li>
	<li><em>ignoreLock</em> ignore remote locking when updating the OBR</li>
</ul>


<p>This goal is part of the "bundle" packaging lifecycle, but is disabled by default - to enable just set the <tt>remoteOBR</tt> parameter.</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:deployfile"></a>bundle:deploy-file</h2>

<p>The <b>deploy-file</b> goal updates the remote OBR with the details of a deployed bundle from the local filesystem. The remote OBR is found using the <tt>-DrepositoryId</tt> and <tt>-Durl</tt> parameters. See <a href="http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html" rel="nofollow">http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html</a> for more details about these particular settings.</p>

<p>You can use the <tt>-DbundleUrl</tt> parameter to give the public location of the deployed bundle, which may differ from the remote OBR location.</p>

<p>configuration:</p>
<ul>
	<li><em>remoteOBR</em> name of remote OBR, defaults to an empty string</li>
	<li><em>obrRepository</em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
	<li><em>repositoryId</em> optional repository id, used to lookup authentication settings</li>
	<li><em>url</em> remote repository transport URL, like
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>scpexe://host/path/to/obr
</pre>
</div></div></li>
	<li><em>bundleUrl</em> public URL of deployed bundle, like
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>http://www.foo.org/bundles/foo.jar
</pre>
</div></div></li>
	<li><em>groupId</em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>artifactId</em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>version</em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>packaging</em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
	<li><em>classifier</em> Maven classifier type, defaults to none</li>
	<li><em>pomFile</em> optional Pom file describing the bundle</li>
	<li><em>file</em> bundle file, defaults to the bundle from the local Maven repository</li>
	<li><em>obrXml</em> optional additional properties for the bundle</li>
	<li><em>ignoreLock</em> ignore remote locking when updating the OBR</li>
</ul>



<p>Example:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>mvn org.apache.felix:maven-bundle-plugin:1.4.0:deploy-file \
  -DpomFile=myPom.xml -Dfile=foo-1.0.jar -Durl=file:/tmp/example/OBR \
  -DbundleUrl=http://www.foo.org/bundles/foo.jar
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-bundle:clean"></a>bundle:clean</h2>

<p>Sometimes you would like to clean your local OBR because it contains
bundles that are no longer in your local Maven repository. This case
often occurs when artifacts were deleted manually. The
maven-bundle-plugin provides a simple goal to check for missing
bundles, and remove them from the local OBR.</p>

<p>configuration:</p>
<ul>
	<li><em>obrRepository</em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
</ul>


<p>Example:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>mvn bundle:clean
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Concurrentupdates"></a>Concurrent updates</h2>

<p>With a remote OBR, several uploads may occur at the same time.
However, the remote OBR is centralized in one file, so concurrent
modification must be avoided. To achieve this, the plug-in implements a
locking system. Each time the plug-in tries to modify the file it sets
a file based lock. If it can't take the lock, it will wait and retry.
After 3 attempts the upload process fails. To bypass this lock add <tt>-DignoreLock</tt> to the command-line (or add <tt>&lt;ignoreLock&gt;true&lt;ignoreLock&gt;</tt> to the configuration section of your Pom).</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-FTPprotocol"></a>FTP protocol</h2>

<p>Not all protocols are supported by Maven out of the box. For example the ftp protocol requires the <b>wagon-ftp</b> component. To enable the ftp protocol add this to your Pom:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;build&gt;</span>
  <span class="code-tag">&lt;extensions&gt;</span>
    <span class="code-tag">&lt;extension&gt;</span>
      <span class="code-tag">&lt;groupId&gt;</span>org.apache.maven.wagon<span class="code-tag">&lt;/groupId&gt;</span>
      <span class="code-tag">&lt;artifactId&gt;</span>wagon-ftp<span class="code-tag">&lt;/artifactId&gt;</span>
      <span class="code-tag">&lt;version&gt;</span>1.0-alpha-6<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag">&lt;/extension&gt;</span>
  <span class="code-tag">&lt;/extensions&gt;</span>
<span class="code-tag">&lt;/build&gt;</span>
</pre>
</div></div>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Howtheplugincomputesthedescriptionofthebundle"></a>How the plug-in computes the description of the bundle</h2>

<p>The description of the bundle comes from three different sources:</p>
<ul>
	<li>Bindex : Bindex is a tool that analyzes a bundle manifest to generate OBR description</li>
	<li>pom.xml : by analyzing the pom file, various information is collected (symbolic name ...)</li>
	<li>obr.xml : this file contains customized description and capabilities for the bundle</li>
</ul>


<p>These sources are merged together using the following precedence:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>Bindex
| (overrides)
pom.xml
| (overrides)
obr.xml
</pre>
</div></div>
<p>A warning message is displayed when existing information is overridden.</p>

<h2><a name="ApacheFelixMavenBundlePlugin(BND)-Knownissues&amp;limitations"></a>Known issues &amp; limitations</h2>

<ol>
	<li>obr.xml (file given by the user to add properties not found
by Bindex) must be correct, because the plug-in does not check its
syntax.</li>
</ol>


<h1><a name="ApacheFelixMavenBundlePlugin(BND)-Feedback"></a>Feedback</h1>

<p>Subscribe to the Felix users mailing list by sending a message to <a href="mailto:users-subscribe@felix.apache.org" rel="nofollow">users-subscribe@felix.apache.org</a>; after subscribing, email questions or feedback to <a href="mailto:users@felix.apache.org" rel="nofollow">users@felix.apache.org</a>.</p>
    </div>
  </body></html>