blob: 11f0e6e218f2d31e9c4df661f3b5ae4036ae5196 [file] [log] [blame]
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Stuart McCulloche1a5f652014-06-20 12:06:22 +00002<!-- saved from url=(0070)http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html -->
3<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Stuart McCulloch5f3ddf72008-05-03 12:49:39 +00004 <title>Apache Felix - Apache Felix Maven Bundle Plugin (BND)</title>
Stuart McCulloche1a5f652014-06-20 12:06:22 +00005 <link rel="stylesheet" href="./apache-felix-maven-bundle-plugin-bnd_files/site.css" type="text/css" media="all">
6
7 <style type="text/css"></style></head>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00008 <body>
Stuart McCulloche1a5f652014-06-20 12:06:22 +00009 <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img border="0" alt="Apache Felix" src="./apache-felix-maven-bundle-plugin-bnd_files/logo.png"></a></div><div class="header"><a href="http://www.apache.org/"><img border="0" alt="Apache" src="./apache-felix-maven-bundle-plugin-bnd_files/apache.png"></a></div></div>
Karl Paulsf87ac142007-07-06 22:36:17 +000010 <div class="menu">
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000011<ul>
Stuart McCulloch93de6492007-12-16 15:59:05 +000012 <li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000013 <li><a href="http://www.apache.org/licenses/" class="external-link" rel="nofollow">license</a></li>
14 <li><a href="http://felix.apache.org/site/downloads.cgi" class="external-link" rel="nofollow">downloads</a></li>
Stuart McCulloch93de6492007-12-16 15:59:05 +000015 <li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li>
16 <li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li>
Stuart McCulloch3f38f732008-05-03 08:13:09 +000017 <li><a href="http://felix.apache.org/site/contributing.html" title="Contributing">contributing</a></li>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000018 <li><a href="http://www.apache.org/" class="external-link" rel="nofollow">asf</a></li>
19 <li><a href="http://www.apache.org/security/" class="external-link" rel="nofollow">security</a></li>
20 <li><a href="http://www.apache.org/foundation/sponsorship.html" class="external-link" rel="nofollow">sponsorship</a></li>
21 <li><a href="http://www.apache.org/foundation/thanks.html" class="external-link" rel="nofollow">sponsors</a>
Stuart McCulloch3f38f732008-05-03 08:13:09 +000022<!-- ApacheCon Ad -->
Stuart McCulloche1a5f652014-06-20 12:06:22 +000023<iframe src="about:blank" style="border-width: 0px; float: left; display: none !important; visibility: hidden !important; opacity: 0 !important; background-position: 135px 135px;" frameborder="0" scrolling="no" width="0" height="0"></iframe>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000024<p style="height: 100px">
25<!-- ApacheCon Ad --></p></li>
26</ul>
27 </div>
Karl Paulsf87ac142007-07-06 22:36:17 +000028 <div class="main">
Stuart McCulloche1a5f652014-06-20 12:06:22 +000029<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-BundlePluginforMaven"></a>Bundle Plugin for Maven</h1>
Karl Paulsf87ac142007-07-06 22:36:17 +000030
Stuart McCulloche1a5f652014-06-20 12:06:22 +000031<p>This plugin for Maven 2 is based on the <a href="http://www.aqute.biz/Bnd/Bnd" class="external-link" 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>
Karl Paulsf87ac142007-07-06 22:36:17 +000032
Stuart McCulloche1a5f652014-06-20 12:06:22 +000033<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" width="16" height="16" align="absmiddle" alt="" border="0"></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" class="external-link" 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" class="external-link" rel="nofollow">Felix user list</a>.</td></tr></tbody></table></div>
Stuart McCullochefb03e42009-09-16 09:47:50 +000034
Stuart McCulloch2eb61122009-02-27 06:38:33 +000035<p><em>NOTE: test scoped dependencies are <b>not</b> included in the classpath seen by BND.</em></p>
Stuart McCulloche23ec842008-08-05 06:36:05 +000036
Stuart McCulloche1a5f652014-06-20 12:06:22 +000037<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>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000038
Stuart McCulloche1a5f652014-06-20 12:06:22 +000039<div class="panelMacro"><table class="tipMacro"><colgroup><col width="24"><col></colgroup><tbody><tr><td valign="top"><img src="./apache-felix-maven-bundle-plugin-bnd_files/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b><a href="http://svn.apache.org/repos/asf/felix/releases/maven-bundle-plugin-2.3.7/doc/site/index.html" class="external-link" rel="nofollow">Standard Maven Documentation is now available for maven-bundle-plugin 2.3.7</a></b></td></tr></tbody></table></div>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000040
Stuart McCulloche1a5f652014-06-20 12:06:22 +000041<div class="panelMacro"><table class="tipMacro"><colgroup><col width="24"><col></colgroup><tbody><tr><td valign="top"><img src="./apache-felix-maven-bundle-plugin-bnd_files/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b><a href="http://www.aqute.biz/Bnd/Format" class="external-link" rel="nofollow">A complete list of instructions and their format is available from the BND website</a></b></td></tr></tbody></table></div>
Stuart McCulloch0340ae42008-02-22 11:27:18 +000042
Stuart McCulloche1a5f652014-06-20 12:06:22 +000043<p><a name="ApacheFelixMavenBundlePlugin%28BND%29-simpleexample"></a></p>
Karl Paulsf87ac142007-07-06 22:36:17 +000044
Stuart McCulloche1a5f652014-06-20 12:06:22 +000045<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-SimpleExample"></a>Simple Example</h1>
Karl Paulsf87ac142007-07-06 22:36:17 +000046
Stuart McCulloche1a5f652014-06-20 12:06:22 +000047<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="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html#ApacheFelixMavenBundlePlugin%2528BND%2529-howto">how to</a>" will follow.</p>
Karl Paulsf87ac142007-07-06 22:36:17 +000048
49<p>Assume that we have a simple bundle project that has a pubic API package an several implementation packages, such as:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +000050
Stuart McCullochefb03e42009-09-16 09:47:50 +000051<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +000052<pre>org.foo.myproject.api
53org.foo.myproject.impl1
54org.foo.myproject.impl2
55...
56</pre>
57</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +000058
Karl Paulsf87ac142007-07-06 22:36:17 +000059<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +000060
Stuart McCullochefb03e42009-09-16 09:47:50 +000061<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +000062<pre>...
63&lt;plugins&gt;
64 &lt;plugin&gt;
65 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
66 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
67 &lt;extensions&gt;true&lt;/extensions&gt;
68 &lt;configuration&gt;
69 &lt;instructions&gt;
70 &lt;Export-Package&gt;org.foo.myproject.api&lt;/Export-Package&gt;
71 &lt;Private-Package&gt;org.foo.myproject.*&lt;/Private-Package&gt;
72 &lt;Bundle-Activator&gt;org.foo.myproject.impl1.Activator&lt;/Bundle-Activator&gt;
73 &lt;/instructions&gt;
74 &lt;/configuration&gt;
75 &lt;/plugin&gt;
76&lt;/plugins&gt;
77...
78</pre>
79</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +000080
Stuart McCulloche1a5f652014-06-20 12:06:22 +000081<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="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html#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>
Karl Paulsf87ac142007-07-06 22:36:17 +000082
Stuart McCulloche1a5f652014-06-20 12:06:22 +000083<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-Features"></a>Features</h1>
Karl Paulsf87ac142007-07-06 22:36:17 +000084
Stuart McCulloche1a5f652014-06-20 12:06:22 +000085<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="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html#ApacheFelixMavenBundlePlugin%2528BND%2529-simpleexample">above</a>. BND recognizes three types of instructions:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +000086
Karl Paulsf87ac142007-07-06 22:36:17 +000087<ol>
Stuart McCulloche1a5f652014-06-20 12:06:22 +000088 <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>
Karl Paulsf87ac142007-07-06 22:36:17 +000089 <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>
Stuart McCulloche1a5f652014-06-20 12:06:22 +000090 <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>
Karl Paulsf87ac142007-07-06 22:36:17 +000091</ol>
92
93
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +000094<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" class="external-link" rel="nofollow">BND documentation</a>.</p>
Karl Paulsf87ac142007-07-06 22:36:17 +000095
Stuart McCulloche1a5f652014-06-20 12:06:22 +000096<p><a name="ApacheFelixMavenBundlePlugin%28BND%29-instructions"></a></p>
Karl Paulsf87ac142007-07-06 22:36:17 +000097
Stuart McCulloche1a5f652014-06-20 12:06:22 +000098<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Instructions"></a>Instructions</h2>
Karl Paulsf87ac142007-07-06 22:36:17 +000099
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000100<h3><a name="ApacheFelixMavenBundlePlugin%28BND%29-%7B%7B%3CExportPackage%3E%7D%7D"></a><tt>&lt;Export-Package&gt;</tt></h3>
Karl Paulsf87ac142007-07-06 22:36:17 +0000101
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000102<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000103
104<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>
105
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000106<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000107
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000108<h3><a name="ApacheFelixMavenBundlePlugin%28BND%29-%7B%7B%3CPrivatePackage%3E%7D%7D"></a><tt>&lt;Private-Package&gt;</tt></h3>
Karl Paulsf87ac142007-07-06 22:36:17 +0000109
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000110<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000111
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000112<h3><a name="ApacheFelixMavenBundlePlugin%28BND%29-%7B%7B%3CIncludeResource%3E%7D%7D"></a><tt>&lt;Include-Resource&gt;</tt></h3>
Karl Paulsf87ac142007-07-06 22:36:17 +0000113
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000114<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000115
Stuart McCullochefb03e42009-09-16 09:47:50 +0000116<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +0000117<pre>clause ::= assignment | inline | simple
118assignment ::= PATH '=' PATH
119simple ::= PATH
120inline ::= '@' PATH
121</pre>
122</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000123
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000124<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000125
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000126<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000127
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000128<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>
129
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000130<h3><a name="ApacheFelixMavenBundlePlugin%28BND%29-%7B%7B%3CImportPackage%3E%7D%7D"></a><tt>&lt;Import-Package&gt;</tt></h3>
Karl Paulsf87ac142007-07-06 22:36:17 +0000131
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000132<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000133
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000134<p><a name="ApacheFelixMavenBundlePlugin%28BND%29-defaultbehavior"></a></p>
Karl Paulsf87ac142007-07-06 22:36:17 +0000135
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000136<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-DefaultBehavior"></a>Default Behavior</h2>
Karl Paulsf87ac142007-07-06 22:36:17 +0000137
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000138<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000139
Karl Paulsf87ac142007-07-06 22:36:17 +0000140<ul>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +0000141 <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" class="external-link" rel="nofollow">Maven2OsgiConverter</a> component, which uses the following algorithm:<br>
Stuart McCulloche23ec842008-08-05 06:36:05 +0000142Get the symbolic name as groupId + "." + artifactId, with the following exceptions:
143 <ul>
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000144 <li>if artifact.getFile is not null and the jar contains a OSGi Manifest with Bundle-SymbolicName property then that value is returned</li>
145 <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>
Stuart McCulloche23ec842008-08-05 06:36:05 +0000146 <li>if artifactId is equal to last section of groupId then groupId is returned. eg. org.apache.maven:maven -&gt; org.apache.maven</li>
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000147 <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>
Stuart McCulloch2eb61122009-02-27 06:38:33 +0000148The 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>
Stuart McCulloche23ec842008-08-05 06:36:05 +0000149 </ul>
150 </li>
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000151 <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>
Stuart McCulloch2eb61122009-02-27 06:38:33 +0000152<em>(before version 2 of the bundleplugin it was based on the symbolic name)</em></li>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +0000153 <li>Since 2.2.0 you can also use {<tt>local-packages</tt>} inside <tt>&lt;Export-Package&gt;</tt> and it will be expanded to the set of local packages.</li>
Stuart McCulloch2eb61122009-02-27 06:38:33 +0000154 <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>
155<em>(before version 2 of the bundleplugin it was assumed to be empty by default)</em></li>
156 <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>
157<em>Any exported packages are also imported by default, to ensure a consistent class space.</em></li>
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000158 <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>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000159 <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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000160 <li><tt>&lt;Bundle-Name&gt;</tt> is assumed to be "<tt>${pom.name</tt>}".</li>
161 <li><tt>&lt;Bundle-Description&gt;</tt> is assumed to be "<tt>${pom.description</tt>}".</li>
162 <li><tt>&lt;Bundle-License&gt;</tt> is assumed to be "<tt>${pom.licenses</tt>}".</li>
163 <li><tt>&lt;Bundle-Vendor&gt;</tt> is assumed to be "<tt>${pom.organization.name</tt>}".</li>
164 <li><tt>&lt;Bundle-DocURL&gt;</tt> is assumed to be "<tt>${pom.organization.url</tt>}".</li>
165</ul>
166
167
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000168<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000169
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000170<p><a name="ApacheFelixMavenBundlePlugin%28BND%29-howto"></a></p>
Karl Paulsf87ac142007-07-06 22:36:17 +0000171
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000172<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-Detailed%22HowTo%22"></a>Detailed "How To"</h1>
Karl Paulsf87ac142007-07-06 22:36:17 +0000173
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000174<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-GetMaven2"></a>Get Maven2</h2>
Karl Paulsf87ac142007-07-06 22:36:17 +0000175
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000176<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" class="external-link" rel="nofollow">Maven website</a>.</p>
Karl Paulsf87ac142007-07-06 22:36:17 +0000177
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000178<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-UsingthePlugin"></a>Using the Plugin</h2>
Karl Paulsf87ac142007-07-06 22:36:17 +0000179
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000180<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000181
Stuart McCullochefb03e42009-09-16 09:47:50 +0000182<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +0000183<pre>&lt;project&gt;
184 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
185 &lt;groupId&gt;my-osgi-bundles&lt;/groupId&gt;
186 &lt;artifactId&gt;examplebundle&lt;/artifactId&gt;
187 &lt;packaging&gt;bundle&lt;/packaging&gt; &lt;!-- (1) --&gt;
188 &lt;version&gt;1.0&lt;/version&gt;
189 &lt;name&gt;Example Bundle&lt;/name&gt;
190 &lt;dependencies&gt;
191 &lt;dependency&gt;
192 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
193 &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000194 &lt;version&gt;1.0.0&lt;/version&gt;
Karl Paulsf87ac142007-07-06 22:36:17 +0000195 &lt;/dependency&gt;
196 &lt;/dependencies&gt;
197 &lt;build&gt;
198 &lt;plugins&gt;
199 &lt;plugin&gt; &lt;!-- (2) START --&gt;
200 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
201 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
202 &lt;extensions&gt;true&lt;/extensions&gt;
203 &lt;configuration&gt;
204 &lt;instructions&gt;
205 &lt;Export-Package&gt;com.my.company.api&lt;/Export-Package&gt;
206 &lt;Private-Package&gt;com.my.company.*&lt;/Private-Package&gt;
207 &lt;Bundle-Activator&gt;com.my.company.Activator&lt;/Bundle-Activator&gt;
208 &lt;/instructions&gt;
209 &lt;/configuration&gt;
210 &lt;/plugin&gt; &lt;!-- (2) END --&gt;
211 &lt;/plugins&gt;
212 &lt;/build&gt;
Karl Paulsf87ac142007-07-06 22:36:17 +0000213&lt;/project&gt;
214</pre>
215</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000216
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000217<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000218
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000219<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-RealWorldExample"></a>Real-World Example</h2>
Karl Paulsf87ac142007-07-06 22:36:17 +0000220
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000221<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000222
Stuart McCullochefb03e42009-09-16 09:47:50 +0000223<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +0000224<pre>&lt;project&gt;
225 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
226 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
227 &lt;artifactId&gt;org.apache.felix.log&lt;/artifactId&gt;
228 &lt;packaging&gt;bundle&lt;/packaging&gt;
229 &lt;name&gt;Apache Felix Log Service&lt;/name&gt;
230 &lt;version&gt;0.8.0-SNAPSHOT&lt;/version&gt;
231 &lt;description&gt;
232 This bundle provides an implementation of the OSGi R4 Log service.
233 &lt;/description&gt;
234 &lt;dependencies&gt;
235 &lt;dependency&gt;
236 &lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
237 &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
238 &lt;version&gt;0.8.0-incubator&lt;/version&gt;
239 &lt;/dependency&gt;
240 &lt;dependency&gt;
241 &lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
242 &lt;artifactId&gt;org.osgi.compendium&lt;/artifactId&gt;
243 &lt;version&gt;0.9.0-incubator-SNAPSHOT&lt;/version&gt;
244 &lt;/dependency&gt;
245 &lt;/dependencies&gt;
246 &lt;build&gt;
247 &lt;plugins&gt;
248 &lt;plugin&gt;
249 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
250 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
251 &lt;extensions&gt;true&lt;/extensions&gt;
252 &lt;configuration&gt;
253 &lt;instructions&gt;
254 &lt;Export-Package&gt;org.osgi.service.log&lt;/Export-Package&gt;
255 &lt;Private-Package&gt;org.apache.felix.log.impl&lt;/Private-Package&gt;
256 &lt;Bundle-SymbolicName&gt;${pom.artifactId}&lt;/Bundle-SymbolicName&gt;
257 &lt;Bundle-Activator&gt;${pom.artifactId}.impl.Activator&lt;/Bundle-Activator&gt;
258 &lt;Export-Service&gt;org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService&lt;/Export-Service&gt;
259 &lt;/instructions&gt;
260 &lt;/configuration&gt;
261 &lt;/plugin&gt;
262 &lt;/plugins&gt;
263 &lt;/build&gt;
Karl Paulsf87ac142007-07-06 22:36:17 +0000264&lt;/project&gt;
265</pre>
266</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000267
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000268<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000269
Stuart McCullochefb03e42009-09-16 09:47:50 +0000270<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +0000271<pre>Manifest-Version: 1
272Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
273Bundle-Activator: org.apache.felix.log.impl.Activator
274Import-Package: org.osgi.framework;version=1.3, org.osgi.service.log;v
275 ersion=1.3
276Include-Resource: src/main/resources
277Export-Package: org.osgi.service.log;uses:=org.osgi.framework;version=
278 1.3
279Bundle-Version: 0.8.0.SNAPSHOT
280Bundle-Name: Apache Felix Log Service
281Bundle-Description: This bundle provides an implementation of the OSGi
282 R4 Log service.
283Private-Package: org.apache.felix.log.impl
284Bundle-ManifestVersion: 2
285Export-Service: org.osgi.service.log.LogService,org.osgi.service.log.L
286 ogReaderService
287Bundle-SymbolicName: org.apache.felix.log
288</pre>
289</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000290
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000291<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000292
Stuart McCullochefb03e42009-09-16 09:47:50 +0000293<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +0000294<pre>META-INF/MANIFEST.MF
295LICENSE
296META-INF/
297META-INF/maven/
298META-INF/maven/org.apache.felix/
299META-INF/maven/org.apache.felix/org.apache.felix.log/
300META-INF/maven/org.apache.felix/org.apache.felix.log/pom.properties
301META-INF/maven/org.apache.felix/org.apache.felix.log/pom.xml
302NOTICE
303org/
304org/apache/
305org/apache/felix/
306org/apache/felix/log/
307org/apache/felix/log/impl/
308org/apache/felix/log/impl/Activator.class
309org/apache/felix/log/impl/Log.class
310org/apache/felix/log/impl/LogEntryImpl.class
311org/apache/felix/log/impl/LogException.class
312org/apache/felix/log/impl/LogListenerThread.class
313org/apache/felix/log/impl/LogNode.class
314org/apache/felix/log/impl/LogNodeEnumeration.class
315org/apache/felix/log/impl/LogReaderServiceFactory.class
316org/apache/felix/log/impl/LogReaderServiceImpl.class
317org/apache/felix/log/impl/LogServiceFactory.class
318org/apache/felix/log/impl/LogServiceImpl.class
319org/osgi/
320org/osgi/service/
321org/osgi/service/log/
322org/osgi/service/log/LogEntry.class
323org/osgi/service/log/LogListener.class
324org/osgi/service/log/LogReaderService.class
325org/osgi/service/log/LogService.class
326org/osgi/service/log/package.html
327org/osgi/service/log/packageinfo
328</pre>
329</div></div>
330
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000331<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-AddingOSGimetadatatoexistingprojectswithoutchangingthepackagingtype"></a>Adding OSGi metadata to existing projects without changing the packaging type</h2>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000332
333<p>If you want to keep your project packaging type (for example "jar") but would like to add OSGi metadata<br>
334you can use the manifest goal to generate a bundle manifest. The maven-jar-plugin can then be used to<br>
335add this manifest to the final artifact. For example:</p>
336
Stuart McCullochefb03e42009-09-16 09:47:50 +0000337<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000338<pre class="code-xml"><span class="code-tag">&lt;plugin&gt;</span>
339 <span class="code-tag">&lt;artifactId&gt;</span>maven-jar-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
340 <span class="code-tag">&lt;configuration&gt;</span>
341 <span class="code-tag">&lt;archive&gt;</span>
342 <span class="code-tag">&lt;manifestFile&gt;</span>${project.build.outputDirectory}/META-INF/MANIFEST.MF<span class="code-tag">&lt;/manifestFile&gt;</span>
343 <span class="code-tag">&lt;/archive&gt;</span>
344 <span class="code-tag">&lt;/configuration&gt;</span>
345<span class="code-tag">&lt;/plugin&gt;</span>
346<span class="code-tag">&lt;plugin&gt;</span>
347 <span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
348 <span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
349 <span class="code-tag">&lt;executions&gt;</span>
350 <span class="code-tag">&lt;execution&gt;</span>
351 <span class="code-tag">&lt;id&gt;</span>bundle-manifest<span class="code-tag">&lt;/id&gt;</span>
352 <span class="code-tag">&lt;phase&gt;</span>process-classes<span class="code-tag">&lt;/phase&gt;</span>
353 <span class="code-tag">&lt;goals&gt;</span>
354 <span class="code-tag">&lt;goal&gt;</span>manifest<span class="code-tag">&lt;/goal&gt;</span>
355 <span class="code-tag">&lt;/goals&gt;</span>
356 <span class="code-tag">&lt;/execution&gt;</span>
357 <span class="code-tag">&lt;/executions&gt;</span>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000358<span class="code-tag">&lt;/plugin&gt;</span>
359</pre>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000360</div></div>
361
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000362<p>If you want to use packaging types other than "jar" and "bundle" then you also need to enable support<br>
363for them in the bundleplugin configuration, for example if you want to use the plugin with WAR files:</p>
364
Stuart McCullochefb03e42009-09-16 09:47:50 +0000365<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000366<pre class="code-xml"><span class="code-tag">&lt;plugin&gt;</span>
367 <span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
368 <span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
369 <span class="code-tag">&lt;executions&gt;</span>
370 <span class="code-tag">&lt;execution&gt;</span>
371 <span class="code-tag">&lt;id&gt;</span>bundle-manifest<span class="code-tag">&lt;/id&gt;</span>
372 <span class="code-tag">&lt;phase&gt;</span>process-classes<span class="code-tag">&lt;/phase&gt;</span>
373 <span class="code-tag">&lt;goals&gt;</span>
374 <span class="code-tag">&lt;goal&gt;</span>manifest<span class="code-tag">&lt;/goal&gt;</span>
375 <span class="code-tag">&lt;/goals&gt;</span>
376 <span class="code-tag">&lt;/execution&gt;</span>
377 <span class="code-tag">&lt;/executions&gt;</span>
378 <span class="code-tag">&lt;configuration&gt;</span>
379 <span class="code-tag">&lt;supportedProjectTypes&gt;</span>
380 <span class="code-tag">&lt;supportedProjectType&gt;</span>jar<span class="code-tag">&lt;/supportedProjectType&gt;</span>
381 <span class="code-tag">&lt;supportedProjectType&gt;</span>bundle<span class="code-tag">&lt;/supportedProjectType&gt;</span>
382 <span class="code-tag">&lt;supportedProjectType&gt;</span>war<span class="code-tag">&lt;/supportedProjectType&gt;</span>
383 <span class="code-tag">&lt;/supportedProjectTypes&gt;</span>
384 <span class="code-tag">&lt;instructions&gt;</span>
385 <span class="code-tag"><span class="code-comment">&lt;!-- ...etc... --&gt;</span></span>
386 <span class="code-tag">&lt;/instructions&gt;</span>
387 <span class="code-tag">&lt;/configuration&gt;</span>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000388<span class="code-tag">&lt;/plugin&gt;</span>
389</pre>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000390</div></div>
391
Stuart McCullochfc1018e2013-06-07 23:34:51 +0000392<p>You'll also need to configure the other plugin to pick up and use the generated manifest, which is written to <tt>${project.build.outputDirectory}/META-INF/MANIFEST.MF</tt> by default (unless you choose a different <tt>manifestLocation</tt> in the maven-bundle-plugin configuration). Continuing with our WAR example:</p>
393
394<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
395<pre class="code-java">&lt;plugin&gt;
396 &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
397 &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
398 &lt;configuration&gt;
399 &lt;archive&gt;
400 &lt;manifestFile&gt;${project.build.outputDirectory}/META-INF/MANIFEST.MF&lt;/manifestFile&gt;
401 &lt;/archive&gt;
402 &lt;/configuration&gt;
403&lt;/plugin&gt;
404</pre>
405</div></div>
406
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000407<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-BuildingthePlugin"></a>Building the Plugin</h2>
Karl Paulsf87ac142007-07-06 22:36:17 +0000408
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000409<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>
Karl Paulsf87ac142007-07-06 22:36:17 +0000410
411<p>Using the SVN client of your choice, checkout the maven-bundle-plugin project.</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000412
Stuart McCullochefb03e42009-09-16 09:47:50 +0000413<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000414<pre>$ svn co http://svn.apache.org/repos/asf/felix/trunk/bundleplugin
Karl Paulsf87ac142007-07-06 22:36:17 +0000415</pre>
416</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000417
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000418<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000419
Stuart McCullochefb03e42009-09-16 09:47:50 +0000420<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Karl Paulsf87ac142007-07-06 22:36:17 +0000421<pre>$ mvn install
422</pre>
423</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000424
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000425<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-Goals"></a>Goals</h1>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000426
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000427<p>The maven-bundle-plugin also provides additional functionality via some Maven goals. Command-line execution of a goal is performed as follows:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000428
Stuart McCullochefb03e42009-09-16 09:47:50 +0000429<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000430<pre>mvn org.apache.felix:maven-bundle-plugin:GOAL
431</pre>
432</div></div>
433
434<p>Where GOAL is one of the following:</p>
435
436<ul>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000437 <li><b><tt>bundle</tt></b> - build an OSGi bundle jar for the current project<br>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000438configuration options:
439 <ul>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000440 <li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li>
441 <li><em><tt>unpackBundle</tt></em> unpack bundle contents to output directory, defaults to false</li>
Stuart McCulloch2eb61122009-02-27 06:38:33 +0000442 <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>
443Version 2 of the bundleplugin now supports the same style of filter clauses in <tt>excludeDependencies</tt> as <tt>Embed-Dependency</tt>.</li>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000444 <li><em><tt>classifier</tt></em> attach bundle to the project using the given classifier</li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000445 <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000446 </ul>
447 </li>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000448</ul>
449
450
451<ul>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000452 <li><b><tt>bundleall</tt></b> - build OSGi bundle jars for all transitive dependencies<br>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000453configuration options:
454 <ul>
Stuart McCulloch5f3ddf72008-05-03 12:49:39 +0000455 <li><em><tt>wrapImportPackage</tt></em> defaults to "*"</li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000456 <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000457 </ul>
458 </li>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000459</ul>
460
461
462<ul>
463 <li><b><tt>wrap</tt></b> - as above, but limited to the first level of dependencies<br>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000464configuration options:
465 <ul>
Stuart McCulloch5f3ddf72008-05-03 12:49:39 +0000466 <li><em><tt>wrapImportPackage</tt></em> defaults to "*"</li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000467 <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000468 </ul>
469 </li>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000470</ul>
471
472
473<ul>
474 <li><b><tt>manifest</tt></b> - create an OSGi manifest for the current project<br>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000475configuration options:
476 <ul>
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000477 <li><em><tt>manifestLocation</tt></em> defaults to ${project.build.outputDirectory}/META-INF</li>
478 <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000479 </ul>
480 </li>
481</ul>
482
483
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000484<ul>
485 <li><b><tt>install</tt></b> - adds the current bundle project to the local OBR<br>
486configuration options:
487 <ul>
488 <li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000489 <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000490 </ul>
491 </li>
492</ul>
493
494
495<p>More GOALs are available in the <b>1.4.0</b> release:</p>
496
497<ul>
498 <li><b><tt>ant</tt></b> - create an Ant build script to rebuild the bundle</li>
499</ul>
500
501
502<ul>
503 <li><b><tt>install-file</tt></b> - adds a local bundle file to the local OBR<br>
504configuration options:
505 <ul>
506 <li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
507 <li><em><tt>groupId</tt></em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
508 <li><em><tt>artifactId</tt></em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
509 <li><em><tt>version</tt></em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
510 <li><em><tt>packaging</tt></em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
511 <li><em><tt>classifier</tt></em> Maven classifier type, defaults to none</li>
512 <li><em><tt>pomFile</tt></em> optional Pom file describing the bundle</li>
513 <li><em><tt>file</tt></em> bundle file, defaults to the bundle from the local Maven repository</li>
514 <li><em><tt>obrXml</tt></em> optional additional properties for the bundle</li>
515 </ul>
516 </li>
517</ul>
518
519
520<ul>
521 <li><b><tt>deploy</tt></b> - adds the current bundle project to a remote OBR<br>
522configuration options:
523 <ul>
524 <li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to NONE (which means no remote OBR deployment)</li>
525 <li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000526 <li><em><tt>prefixUrl</tt></em> optional public URL prefix for the remote repository</li>
527 <li><em><tt>bundleUrl</tt></em> optional public URL where the bundle has been deployed</li>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000528 <li><em><tt>altDeploymentRepository</tt></em> alternative remote repository, <em>id::layout::url</em></li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000529 <li><em><tt>obrDeploymentRepository</tt></em> optional OBR specific deployment repository.</li>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000530 <li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000531 <li><em><tt>supportedProjectTypes</tt></em> defaults to "jar","bundle"</li>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000532 </ul>
533 </li>
534</ul>
535
536
537<ul>
538 <li><b><tt>deploy-file</tt></b> - adds a local bundle file to a remote OBR<br>
539configuration options:
540 <ul>
541 <li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to an empty string</li>
542 <li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
543 <li><em><tt>repositoryId</tt></em> optional repository id, used to lookup authentication settings</li>
544 <li><em><tt>url</tt></em> remote repository transport URL, like
Stuart McCullochefb03e42009-09-16 09:47:50 +0000545<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000546<pre>scpexe://host/path/to/obr
547</pre>
548</div></div></li>
549 <li><em><tt>bundleUrl</tt></em> public URL of deployed bundle, like
Stuart McCullochefb03e42009-09-16 09:47:50 +0000550<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000551<pre>http://www.foo.org/bundles/foo.jar
552</pre>
553</div></div></li>
554 <li><em><tt>groupId</tt></em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
555 <li><em><tt>artifactId</tt></em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
556 <li><em><tt>version</tt></em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
557 <li><em><tt>packaging</tt></em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
558 <li><em><tt>classifier</tt></em> Maven classifier type, defaults to none</li>
559 <li><em><tt>pomFile</tt></em> optional Pom file describing the bundle</li>
560 <li><em><tt>file</tt></em> bundle file, defaults to the bundle from the local Maven repository</li>
561 <li><em><tt>obrXml</tt></em> optional additional properties for the bundle</li>
562 <li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li>
563 </ul>
564 </li>
565</ul>
566
567
568<ul>
569 <li><b><tt>clean</tt></b> - cleans the local OBR, removing missing bundles<br>
570configuration options:
571 <ul>
572 <li><em><tt>obrRepository</tt></em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
573 </ul>
574 </li>
575</ul>
576
577
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000578<ul>
579 <li><b><tt>remote-clean</tt></b> - cleans a remote OBR, removing missing bundles<br>
580configuration options:
581 <ul>
582 <li><em><tt>remoteOBR</tt></em> name of remote OBR, defaults to NONE (which means no remote cleaning)</li>
583 <li><em><tt>obrRepository</tt></em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
584 <li><em><tt>prefixUrl</tt></em> optional public URL prefix for the remote repository</li>
585 <li><em><tt>altDeploymentRepository</tt></em> alternative remote repository, <em>id::layout::url</em></li>
586 <li><em><tt>obrDeploymentRepository</tt></em> optional OBR specific deployment repository.</li>
587 <li><em><tt>ignoreLock</tt></em> ignore remote locking when updating the OBR</li>
588 </ul>
589 </li>
590</ul>
591
592
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000593<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" class="external-link" rel="nofollow">BND documentation</a>.</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000594
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000595<p>The default goal <b><tt>bundle</tt></b> will be initialized by setting the &lt;packaging&gt; entry to "bundle".</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000596
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000597<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-Thefollowingfeaturesareonlyavailablefromversion1.2.0onwards"></a>The following features are only available from version 1.2.0 onwards</h1>
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000598
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000599<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Embeddingdependencies"></a>Embedding dependencies</h2>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000600
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000601<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000602
Stuart McCullochefb03e42009-09-16 09:47:50 +0000603<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
604<pre class="code-xml"><span class="code-tag">&lt;Embed-Dependency&gt;</span>dependencies<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
605</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000606</div></div>
607
608<p>where:</p>
609
Stuart McCullochefb03e42009-09-16 09:47:50 +0000610<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000611<pre>dependencies ::= clause ( ',' clause ) *
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000612clause ::= MATCH ( ';' attr '=' MATCH | ';inline=' inline )
Stuart McCullochefb03e42009-09-16 09:47:50 +0000613attr ::= 'groupId' | 'artifactId' | 'version' | 'scope' | 'type' | 'classifier' | 'optional'
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000614inline ::= 'true' | 'false' | PATH ( '|' PATH ) *
615MATCH ::= &lt;globbed regular expression&gt;
616PATH ::= &lt;Ant-style path expression&gt;
Stuart McCulloch93de6492007-12-16 15:59:05 +0000617</pre>
618</div></div>
619
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000620<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>
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000621
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +0000622<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 zero or one character. You can also use standard Java <a href="http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html" class="external-link" rel="nofollow">regexp</a> constructs. There is no need to escape the <b>.</b> character inside MATCH. The first MATCH in a clause will filter against the artifactId.</p>
Stuart McCulloch3f38f732008-05-03 08:13:09 +0000623
Stuart McCulloch93de6492007-12-16 15:59:05 +0000624<p>some examples:</p>
625
Stuart McCullochefb03e42009-09-16 09:47:50 +0000626<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCulloch3f38f732008-05-03 08:13:09 +0000627<pre class="code-xml"><span class="code-tag"><span class="code-comment">&lt;!-- embed all compile and runtime scope dependencies --&gt;</span></span>
628<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=compile|runtime<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000629
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000630<span class="code-tag"><span class="code-comment">&lt;!-- embed any dependencies with artifactId junit and scope runtime --&gt;</span></span>
631<span class="code-tag">&lt;Embed-Dependency&gt;</span>junit;scope=runtime<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000632
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000633<span class="code-tag"><span class="code-comment">&lt;!-- inline all non-pom dependencies, except those with scope runtime --&gt;</span></span>
634<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=!runtime;type=!pom;inline=true<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
Stuart McCulloch3f38f732008-05-03 08:13:09 +0000635
636<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>
Stuart McCulloch1bcd7952009-02-26 21:29:51 +0000637<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>
638
639<span class="code-tag"><span class="code-comment">&lt;!-- inline contents of selected folders from all dependencies --&gt;</span></span>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000640<span class="code-tag">&lt;Embed-Dependency&gt;</span>*;inline=images/**|icons/**<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
641</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000642</div></div>
643
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000644<p>examples of using {<tt>maven-dependencies</tt>}:</p>
645
Stuart McCullochefb03e42009-09-16 09:47:50 +0000646<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000647<pre class="code-xml"><span class="code-tag">&lt;Include-Resource&gt;</span>
648 {maven-resources}, {maven-dependencies},
649 org/foo/Example.class=target/classes/org/foo/Example.class
650<span class="code-tag">&lt;/Include-Resource&gt;</span>
651
Stuart McCullochefb03e42009-09-16 09:47:50 +0000652<span class="code-tag">&lt;Bundle-ClassPath&gt;</span>.,{maven-dependencies},some.jar<span class="code-tag">&lt;/Bundle-ClassPath&gt;</span>
653</pre>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000654</div></div>
655
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000656<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000657
658<ul>
659 <li><tt>&lt;Embed-StripVersion&gt;true&lt;/Embed-StripVersion&gt;</tt> - removes the version from the file (ie. <em>artifactId.jar</em>)</li>
660 <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>
661 <li><tt>&lt;Embed-Directory&gt;directory&lt;/Embed-Directory&gt;</tt> - adds a subdirectory (ie. <em>directory/artifactId-version.jar</em>)</li>
662</ul>
663
664
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000665<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000666
Stuart McCullochefb03e42009-09-16 09:47:50 +0000667<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
668<pre class="code-xml"><span class="code-tag">&lt;Embed-Transitive&gt;</span>true<span class="code-tag">&lt;/Embed-Transitive&gt;</span>
669</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000670</div></div>
671
672<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>
673
Stuart McCullochefb03e42009-09-16 09:47:50 +0000674<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
675<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>
676</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000677</div></div>
678
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000679<h3><a name="ApacheFelixMavenBundlePlugin%28BND%29-EmbedDependencyandExportPackage"></a>Embed-Dependency and Export-Package</h3>
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000680
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000681<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>
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000682
683<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000684
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000685<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-OBRintegration"></a>OBR integration</h2>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000686
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000687<p>The latest Maven Bundle Plugin automatically updates the local OBR repository.xml file during the install phase, using a default location of:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000688
Stuart McCullochefb03e42009-09-16 09:47:50 +0000689<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
690<pre class="code-java">&lt;LOCAL-MAVEN-REPOSITORY&gt;/repository.xml
691</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000692</div></div>
693
694<p>You can configure the location of the OBR repository by using the command line:</p>
695
Stuart McCullochefb03e42009-09-16 09:47:50 +0000696<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
697<pre class="code-java">mvn clean install -DobrRepository=&lt;PATH_TO_OBR&gt;
698</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000699</div></div>
700
701<p>or in the configuration section for the maven-bundle-plugin in your Maven POM:</p>
702
Stuart McCullochefb03e42009-09-16 09:47:50 +0000703<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000704<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
705<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
706<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
707<span class="code-tag">&lt;configuration&gt;</span>
708 <span class="code-tag">&lt;obrRepository&gt;</span>PATH_TO_OBR<span class="code-tag">&lt;/obrRepository&gt;</span>
709 <span class="code-tag">&lt;instructions&gt;</span>
710 <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
711 <span class="code-tag">&lt;/instructions&gt;</span>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000712<span class="code-tag">&lt;/configuration&gt;</span>
713</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000714</div></div>
715
716<p>to disable OBR installation set the obrRepository to NONE, for example:</p>
717
Stuart McCullochefb03e42009-09-16 09:47:50 +0000718<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000719<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
720<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
721<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
722<span class="code-tag">&lt;configuration&gt;</span>
723 <span class="code-tag">&lt;obrRepository&gt;</span>NONE<span class="code-tag">&lt;/obrRepository&gt;</span>
724 <span class="code-tag">&lt;instructions&gt;</span>
725 <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
726 <span class="code-tag">&lt;/instructions&gt;</span>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000727<span class="code-tag">&lt;/configuration&gt;</span>
728</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000729</div></div>
730
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000731<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Eclipse%2FPDEintegration"></a>Eclipse/PDE integration</h2>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000732
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000733<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000734
Stuart McCullochefb03e42009-09-16 09:47:50 +0000735<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000736<pre>&lt;project&gt;
737
738 &lt;properties&gt;
739 &lt;bundle.symbolicName&gt;org.example&lt;/bundle.symbolicName&gt;
740 &lt;bundle.namespace&gt;org.example&lt;/bundle.namespace&gt;
741 &lt;/properties&gt;
742
743 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
744 &lt;groupId&gt;examples&lt;/groupId&gt;
745 &lt;artifactId&gt;org.example&lt;/artifactId&gt;
746 &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
747
748 &lt;name&gt;${bundle.symbolicName} [${bundle.namespace}]&lt;/name&gt;
749
750 &lt;packaging&gt;bundle&lt;/packaging&gt;
751
752 &lt;build&gt;
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000753 &lt;resources&gt;
754 &lt;resource&gt;
755 &lt;directory&gt;src/main/resources&lt;/directory&gt;
756 &lt;/resource&gt;
757 &lt;resource&gt;
758 &lt;directory&gt;.&lt;/directory&gt;
759 &lt;includes&gt;
760 &lt;include&gt;plugin.xml&lt;/include&gt;
761 &lt;/includes&gt;
762 &lt;/resource&gt;
763 &lt;/resources&gt;
Stuart McCulloch93de6492007-12-16 15:59:05 +0000764 &lt;plugins&gt;
765 &lt;plugin&gt;
766 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
767 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000768 &lt;version&gt;1.2.1&lt;/version&gt;
Stuart McCulloch93de6492007-12-16 15:59:05 +0000769 &lt;extensions&gt;true&lt;/extensions&gt;
770 &lt;!--
771 the following instructions build a simple set of public/private classes into an OSGi bundle
772 --&gt;
773 &lt;configuration&gt;
774 &lt;manifestLocation&gt;META-INF&lt;/manifestLocation&gt;
775 &lt;instructions&gt;
776 &lt;Bundle-SymbolicName&gt;${bundle.symbolicName}&lt;/Bundle-SymbolicName&gt;
777 &lt;Bundle-Version&gt;${pom.version}&lt;/Bundle-Version&gt;
778 &lt;!--
779 assume public classes are in the top package, and private classes are under ".internal"
780 --&gt;
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000781 &lt;Export-Package&gt;!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${pom.version}"&lt;/Export-Package&gt;
782 &lt;Private-Package&gt;${bundle.namespace}.internal.*&lt;/Private-Package&gt;
783 &lt;Bundle-Activator&gt;${bundle.namespace}.internal.ExampleActivator&lt;/Bundle-Activator&gt;
Stuart McCulloch93de6492007-12-16 15:59:05 +0000784 &lt;!--
785 embed compile/runtime dependencies using path that matches the copied dependency folder
786 --&gt;
787 &lt;Embed-Dependency&gt;*;scope=compile|runtime;inline=false&lt;/Embed-Dependency&gt;
788 &lt;Embed-Directory&gt;target/dependency&lt;/Embed-Directory&gt;
789 &lt;Embed-StripGroup&gt;true&lt;/Embed-StripGroup&gt;
790 &lt;/instructions&gt;
791 &lt;/configuration&gt;
792 &lt;/plugin&gt;
793 &lt;plugin&gt;
794 &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
795 &lt;executions&gt;
796 &lt;execution&gt;
797 &lt;id&gt;copy-dependencies&lt;/id&gt;
798 &lt;phase&gt;package&lt;/phase&gt;
799 &lt;goals&gt;
800 &lt;goal&gt;copy-dependencies&lt;/goal&gt;
801 &lt;/goals&gt;
802 &lt;/execution&gt;
803 &lt;/executions&gt;
804 &lt;/plugin&gt;
805 &lt;/plugins&gt;
806 &lt;/build&gt;
807
808 &lt;dependencies&gt;
809 &lt;dependency&gt;
810 &lt;groupId&gt;org.osgi&lt;/groupId&gt;
811 &lt;artifactId&gt;osgi_R4_core&lt;/artifactId&gt;
812 &lt;version&gt;1.0&lt;/version&gt;
813 &lt;scope&gt;provided&lt;/scope&gt;
814 &lt;optional&gt;true&lt;/optional&gt;
815 &lt;/dependency&gt;
816 &lt;dependency&gt;
817 &lt;groupId&gt;org.osgi&lt;/groupId&gt;
818 &lt;artifactId&gt;osgi_R4_compendium&lt;/artifactId&gt;
819 &lt;version&gt;1.0&lt;/version&gt;
820 &lt;scope&gt;provided&lt;/scope&gt;
821 &lt;optional&gt;true&lt;/optional&gt;
822 &lt;/dependency&gt;
823 &lt;dependency&gt;
824 &lt;groupId&gt;junit&lt;/groupId&gt;
825 &lt;artifactId&gt;junit&lt;/artifactId&gt;
826 &lt;version&gt;3.8.1&lt;/version&gt;
827 &lt;scope&gt;compile&lt;/scope&gt;
828 &lt;optional&gt;true&lt;/optional&gt;
829 &lt;/dependency&gt;
830 &lt;/dependencies&gt;
831
832&lt;/project&gt;
833</pre>
834</div></div>
835
836<p>To generate the Eclipse metadata use:</p>
837
Stuart McCullochefb03e42009-09-16 09:47:50 +0000838<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
839<pre class="code-java">mvn clean <span class="code-keyword">package</span> eclipse:eclipse -Declipse.pde install
840</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000841</div></div>
842
843<p>and you should now be able to import this as an existing Eclipse project.</p>
844
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +0000845<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" class="external-link" rel="nofollow">Pax-Construct</a> and then tweaked to demonstrate using the Maven Dependency Plugin to handle embedded jars in Eclipse.</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000846
847<p>With the original Pax-Construct generated POM you would simply use:</p>
848
Stuart McCullochefb03e42009-09-16 09:47:50 +0000849<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
850<pre class="code-java">mvn clean <span class="code-keyword">package</span> pax:eclipse
851</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000852</div></div>
853
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000854<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000855
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000856<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Unpackingbundlecontentsto%27target%2Fclasses%27"></a>Unpacking bundle contents to 'target/classes'</h2>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000857
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000858<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000859
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000860<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>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000861
Stuart McCullochefb03e42009-09-16 09:47:50 +0000862<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000863<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
864<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
865<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
866<span class="code-tag">&lt;configuration&gt;</span>
867 <span class="code-tag">&lt;unpackBundle&gt;</span>true<span class="code-tag">&lt;/unpackBundle&gt;</span>
868 <span class="code-tag">&lt;instructions&gt;</span>
869 <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
870 <span class="code-tag">&lt;/instructions&gt;</span>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000871<span class="code-tag">&lt;/configuration&gt;</span>
872</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000873</div></div>
874
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000875<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-UsinganexistingMANIFEST.MFfile"></a>Using an existing MANIFEST.MF file</h2>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000876
877<p>If you have an existing manifest, you can add this to the Bnd instructions, like so:</p>
878
Stuart McCullochefb03e42009-09-16 09:47:50 +0000879<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCullochdd4ae5f2008-02-05 12:38:46 +0000880<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>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000881<span class="code-tag">&lt;Export-Package&gt;</span>org.example.*<span class="code-tag">&lt;/Export-Package&gt;</span>
882</pre>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000883</div></div>
884
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000885<p>Bnd will use it when calculating the bundle contents, and will also copy across all manifest attributes starting with a capital letter.<br>
886As shown in the above example, you could use this to include a non-OSGi manifest which you then customize with extra OSGi attributes.</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000887
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000888<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-Thefollowingfeaturesareonlyavailablefromversion1.4.0onwards"></a>The following features are only available from version 1.4.0 onwards</h1>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000889
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000890<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-bundle%3Aant"></a>bundle:ant</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000891
892<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>
893
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000894<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>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000895
896<p>Example:</p>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000897<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000898<pre>mvn ant:ant bundle:ant
899
900ant clean package
901</pre>
902</div></div>
903
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000904<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-bundle%3Ainstallfile"></a>bundle:install-file</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000905
906<p>The <b>install-file</b> goal updates the local OBR with the details of a bundle from the local filesystem.</p>
907
908<p>configuration:</p>
909<ul>
910 <li><em>obrRepository</em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
911 <li><em>groupId</em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
912 <li><em>artifactId</em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
913 <li><em>version</em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
914 <li><em>packaging</em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
915 <li><em>classifier</em> Maven classifier type, defaults to none</li>
916 <li><em>pomFile</em> optional Pom file describing the bundle</li>
917 <li><em>file</em> bundle file, defaults to the bundle from the local Maven repository</li>
918 <li><em>obrXml</em> optional additional properties for the bundle</li>
919</ul>
920
921
922<p>Example:</p>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000923<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000924<pre>mvn org.apache.felix:maven-bundle-plugin:1.4.0:install-file \
925 -DpomFile=myPom.xml -Dfile=foo-1.0.jar
926</pre>
927</div></div>
928
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000929<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-bundle%3Adeploy"></a>bundle:deploy</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000930
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000931<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" class="external-link" rel="nofollow">http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html</a> for more details about these particular settings.</p>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000932
933<p>(If the project has an <tt>obr.xml</tt> file somewhere in its resources, then it will be automatically detected and applied.)</p>
934
935<p>configuration:</p>
936<ul>
937 <li><em>remoteOBR</em> name of remote OBR, defaults to NONE (which means no remote OBR deployment)</li>
938 <li><em>obrRepository</em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
939 <li><em>altDeploymentRepository</em> alternative remote repository, <em>id::layout::url</em></li>
940 <li><em>ignoreLock</em> ignore remote locking when updating the OBR</li>
941</ul>
942
943
944<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>
945
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000946<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-bundle%3Adeployfile"></a>bundle:deploy-file</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000947
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +0000948<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" class="external-link" rel="nofollow">http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html</a> for more details about these particular settings.</p>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000949
950<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>
951
952<p>configuration:</p>
953<ul>
954 <li><em>remoteOBR</em> name of remote OBR, defaults to an empty string</li>
955 <li><em>obrRepository</em> used when the remoteOBR name is blank, defaults to <tt>repository.xml</tt></li>
956 <li><em>repositoryId</em> optional repository id, used to lookup authentication settings</li>
957 <li><em>url</em> remote repository transport URL, like
Stuart McCullochefb03e42009-09-16 09:47:50 +0000958<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000959<pre>scpexe://host/path/to/obr
960</pre>
961</div></div></li>
962 <li><em>bundleUrl</em> public URL of deployed bundle, like
Stuart McCullochefb03e42009-09-16 09:47:50 +0000963<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000964<pre>http://www.foo.org/bundles/foo.jar
965</pre>
966</div></div></li>
967 <li><em>groupId</em> Maven groupId for the bundle, taken from <em>pomFile</em> if given</li>
968 <li><em>artifactId</em> Maven artifactId for the bundle, taken from <em>pomFile</em> if given</li>
969 <li><em>version</em> Maven version for the bundle, taken from <em>pomFile</em> if given</li>
970 <li><em>packaging</em> Maven packaging type for the bundle, taken from <em>pomFile</em> if given</li>
971 <li><em>classifier</em> Maven classifier type, defaults to none</li>
972 <li><em>pomFile</em> optional Pom file describing the bundle</li>
973 <li><em>file</em> bundle file, defaults to the bundle from the local Maven repository</li>
974 <li><em>obrXml</em> optional additional properties for the bundle</li>
975 <li><em>ignoreLock</em> ignore remote locking when updating the OBR</li>
976</ul>
977
978
Stuart McCulloch2eb61122009-02-27 06:38:33 +0000979
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000980<p>Example:</p>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000981<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000982<pre>mvn org.apache.felix:maven-bundle-plugin:1.4.0:deploy-file \
983 -DpomFile=myPom.xml -Dfile=foo-1.0.jar -Durl=file:/tmp/example/OBR \
984 -DbundleUrl=http://www.foo.org/bundles/foo.jar
985</pre>
986</div></div>
987
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000988<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-bundle%3Aclean"></a>bundle:clean</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000989
Stuart McCulloche1a5f652014-06-20 12:06:22 +0000990<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>
Stuart McCulloch0340ae42008-02-22 11:27:18 +0000991
992<p>configuration:</p>
993<ul>
994 <li><em>obrRepository</em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
995</ul>
996
997
998<p>Example:</p>
Stuart McCullochefb03e42009-09-16 09:47:50 +0000999<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001000<pre>mvn bundle:clean
1001</pre>
1002</div></div>
1003
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001004<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-bundle%3Aindex"></a>bundle:index</h2>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00001005
1006<p>The <tt>index</tt> goal allows the creation of an OBR repository based on a set of jars in a maven repository.</p>
1007
1008<p>Configuration:</p>
1009<ul>
1010 <li><em>obrRepository</em> path to local OBR, defaults to <em>&lt;local-maven-repository&gt;</em><tt>/repository.xml</tt></li>
1011 <li><em>urlTemplate</em> template for generating urls for OBR resources</li>
1012 <li><em>mavenRepository</em> path to the maven repository, defaults to <em>&lt;local-maven-repository&gt;</em></li>
1013</ul>
1014
1015
1016<p>Possible values for the <tt>urlTemplate</tt> are:</p>
1017<ul>
1018 <li><em>maven</em> this will create a maven based url such as <tt>mvn:groupid/artifactid/version</tt></li>
1019 <li>pattern with the following placeholders:
1020 <ul>
1021 <li><tt>%v</tt> bundle version</li>
1022 <li><tt>%s</tt> bundle symbolic name</li>
1023 <li><tt>%f</tt> file name</li>
1024 <li><tt>%p</tt> file path</li>
1025 </ul>
1026 </li>
1027</ul>
1028
1029
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001030<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Concurrentupdates"></a>Concurrent updates</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001031
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001032<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>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001033
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001034<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-FTPprotocol"></a>FTP protocol</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001035
1036<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>
Stuart McCullochefb03e42009-09-16 09:47:50 +00001037<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001038<pre class="code-xml"><span class="code-tag">&lt;build&gt;</span>
1039 <span class="code-tag">&lt;extensions&gt;</span>
1040 <span class="code-tag">&lt;extension&gt;</span>
1041 <span class="code-tag">&lt;groupId&gt;</span>org.apache.maven.wagon<span class="code-tag">&lt;/groupId&gt;</span>
1042 <span class="code-tag">&lt;artifactId&gt;</span>wagon-ftp<span class="code-tag">&lt;/artifactId&gt;</span>
1043 <span class="code-tag">&lt;version&gt;</span>1.0-alpha-6<span class="code-tag">&lt;/version&gt;</span>
1044 <span class="code-tag">&lt;/extension&gt;</span>
1045 <span class="code-tag">&lt;/extensions&gt;</span>
Stuart McCullochefb03e42009-09-16 09:47:50 +00001046<span class="code-tag">&lt;/build&gt;</span>
1047</pre>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001048</div></div>
1049
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001050<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Howtheplugincomputesthedescriptionofthebundle"></a>How the plug-in computes the description of the bundle</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001051
1052<p>The description of the bundle comes from three different sources:</p>
1053<ul>
1054 <li>Bindex : Bindex is a tool that analyzes a bundle manifest to generate OBR description</li>
1055 <li>pom.xml : by analyzing the pom file, various information is collected (symbolic name ...)</li>
1056 <li>obr.xml : this file contains customized description and capabilities for the bundle</li>
1057</ul>
1058
1059
1060<p>These sources are merged together using the following precedence:</p>
Stuart McCullochefb03e42009-09-16 09:47:50 +00001061<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001062<pre>Bindex
1063| (overrides)
1064pom.xml
1065| (overrides)
1066obr.xml
1067</pre>
1068</div></div>
1069<p>A warning message is displayed when existing information is overridden.</p>
1070
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001071<h2><a name="ApacheFelixMavenBundlePlugin%28BND%29-Knownissues%26limitations"></a>Known issues &amp; limitations</h2>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001072
1073<ol>
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001074 <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>
Stuart McCulloch0340ae42008-02-22 11:27:18 +00001075</ol>
1076
1077
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001078<h1><a name="ApacheFelixMavenBundlePlugin%28BND%29-Feedback"></a>Feedback</h1>
Stuart McCulloch93de6492007-12-16 15:59:05 +00001079
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00001080<p>Subscribe to the Felix users mailing list by sending a message to <a href="mailto:users-subscribe@felix.apache.org" class="external-link" rel="nofollow">users-subscribe@felix.apache.org</a>; after subscribing, email questions or feedback to <a href="mailto:users@felix.apache.org" class="external-link" rel="nofollow">users@felix.apache.org</a>.</p>
1081 <div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
Stuart McCullochfc1018e2013-06-07 23:34:51 +00001082Last modified by mcculls on Wed Nov 21 20:06:53 EST 2012
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00001083 </div>
1084 <div class="trademarkFooter">
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001085Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00001086 </div>
Karl Paulsf87ac142007-07-06 22:36:17 +00001087 </div>
Stuart McCulloch0bb7aba2011-11-28 15:58:52 +00001088
1089
Stuart McCulloche1a5f652014-06-20 12:06:22 +00001090</body></html>