blob: 5fa0afe17e2abe7a820b686a072c30e2da1e4d6a [file] [log] [blame]
Karl Paulsf87ac142007-07-06 22:36:17 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Stuart McCulloch93de6492007-12-16 15:59:05 +00002<html><head><title>Apache Felix - Maven Bundle Plugin (BND)</title>
Karl Paulsf87ac142007-07-06 22:36:17 +00003
4
5
6
7 <link rel="stylesheet" href="maven-bundle-plugin-bnd_files/site.css" type="text/css" media="all">
Karl Paulsf87ac142007-07-06 22:36:17 +00008 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"></head><body>
Stuart McCulloch93de6492007-12-16 15:59:05 +00009 <div class="title"><div class="logo"><a href="http://felix.apache.org/site/index.html"><img alt="Apache Felix" src="maven-bundle-plugin-bnd_files/logo.png" border="0"></a></div><div class="header"><a href="http://www.apache.org/"><img alt="Apache" src="maven-bundle-plugin-bnd_files/apache.png" border="0"></a></div></div>
Karl Paulsf87ac142007-07-06 22:36:17 +000010 <div class="menu">
Stuart McCulloch93de6492007-12-16 15:59:05 +000011<ul>
12 <li><a href="http://felix.apache.org/site/index.html" title="Index">home</a></li>
13 <li><a href="http://felix.apache.org/site/news.html" title="news">news</a></li>
14 <li><a href="http://felix.apache.org/site/status.html" title="status">status</a></li>
15 <li><a href="http://felix.apache.org/site/license.html" title="license">license</a></li>
16 <li><span class="nobr"><a href="http://felix.apache.org/site/downloads.cgi" title="Visit page outside Confluence" rel="nofollow">downloads<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span></li>
17 <li><a href="http://felix.apache.org/site/documentation.html" title="documentation">documentation</a></li>
18 <li><a href="http://felix.apache.org/site/mailinglists.html" title="mailinglists">mailing lists</a></li>
19 <li><span class="nobr"><a href="http://cwiki.apache.org/confluence/x/O-" title="Visit page outside Confluence" rel="nofollow">wiki<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span></li>
20 <li><a href="http://felix.apache.org/site/committers.html" title="committers">committers</a></li>
21 <li><a href="http://felix.apache.org/site/faq.html" title="faq">faq</a></li>
22 <li><a href="http://felix.apache.org/site/roadmap.html" title="roadmap">roadmap</a></li>
23 <li><a href="http://felix.apache.org/site/sourcecode.html" title="sourcecode">source code</a></li>
24 <li><a href="http://felix.apache.org/site/codingstandards.html" title="codingstandards">coding standards</a></li>
25 <li><a href="http://felix.apache.org/site/issuetracking.html" title="issuetracking">issue tracking</a></li>
26 <li><a href="http://felix.apache.org/site/dependencies.html" title="dependencies">dependencies</a></li>
27 <li><span class="nobr"><a href="http://www.apache.org/" title="Visit page outside Confluence" rel="nofollow">apache software foundation<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span></li>
28 <li><span class="nobr"><a href="http://www.apache.org/foundation/sponsorship.html" title="Visit page outside Confluence" rel="nofollow">sponsorship<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span></li>
29 <li><span class="nobr"><a href="http://www.apache.org/foundation/thanks.html" title="Visit page outside Confluence" rel="nofollow">sponsors<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span></li>
30</ul> </div>
Karl Paulsf87ac142007-07-06 22:36:17 +000031 <div class="main">
32<h1><a name="MavenBundlePlugin(BND)-BundlePluginforMaven"></a>Bundle Plugin for Maven</h1>
33
34<p>This plugin for Maven 2 is based on the <span class="nobr"><a href="http://www.aqute.biz/Code/Bnd" title="Visit page outside Confluence" rel="nofollow">BND<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span>
35tool from Peter Kriens. The way BND works is by treating your project
36as a big collection of classes (e.g., project code, dependencies, and
37the class path). The way you create a bundle with BND is to tell it the
38content of the bundle's JAR file as a subset of the available classes.
39This plugin wraps BND to make it work specifically with the Maven 2
40project structure and to provide it with reasonable default behavior
41for Maven 2 projects.</p>
42
43<p><a name="MavenBundlePlugin(BND)-simpleexample"></a></p>
44
45<h1><a name="MavenBundlePlugin(BND)-SimpleExample"></a>Simple Example</h1>
46
47<p>Rather than going straight to a detailed list of plugin features, we
48will first look at a simple example of how to use the plugin to give an
49immediate flavor. A detailed "<a href="#MavenBundlePlugin%2528BND%2529-howto" title="how-to on Maven Bundle Plugin (BND)">how to</a>" will follow.</p>
50
51<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 +000052
Karl Paulsf87ac142007-07-06 22:36:17 +000053<div class="preformatted"><div class="preformattedContent">
54<pre>org.foo.myproject.api
55org.foo.myproject.impl1
56org.foo.myproject.impl2
57...
58</pre>
59</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +000060
Karl Paulsf87ac142007-07-06 22:36:17 +000061<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 +000062
Karl Paulsf87ac142007-07-06 22:36:17 +000063<div class="preformatted"><div class="preformattedContent">
64<pre>...
65&lt;plugins&gt;
66 &lt;plugin&gt;
67 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
68 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
69 &lt;extensions&gt;true&lt;/extensions&gt;
70 &lt;configuration&gt;
71 &lt;instructions&gt;
72 &lt;Export-Package&gt;org.foo.myproject.api&lt;/Export-Package&gt;
73 &lt;Private-Package&gt;org.foo.myproject.*&lt;/Private-Package&gt;
74 &lt;Bundle-Activator&gt;org.foo.myproject.impl1.Activator&lt;/Bundle-Activator&gt;
75 &lt;/instructions&gt;
76 &lt;/configuration&gt;
77 &lt;/plugin&gt;
78&lt;/plugins&gt;
79...
80</pre>
81</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +000082
Karl Paulsf87ac142007-07-06 22:36:17 +000083<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>
84export. If the two sets overlap, as they do in the case, then the
85export takes precedence. Since we did not specify any values for any
86other bundle manifest headers, they will assume default values which
87are described <a href="#MavenBundlePlugin%2528BND%2529-defaultbehavior" title="default-behavior on Maven Bundle Plugin (BND)">below</a>. One specific behavior to highlight is that the plugin generates the <tt>Import-Package</tt>
88bundle manifest header based on the contents of the bundle, which means
89that you generally do not ever need to explicitly specify it yourself.
90That's it.</p>
91
92<h1><a name="MavenBundlePlugin(BND)-Features"></a>Features</h1>
93
94<p>The BND library underlying the plugin defines instructions to direct
95its behavior. For this Maven plugin, these instructions are issued in
96the plugin configuration section of the POM file, as was illustrated <a href="#MavenBundlePlugin%2528BND%2529-simpleexample" title="simple-example on Maven Bundle Plugin (BND)">above</a>. BND recognizes three types of instructions:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +000097
Karl Paulsf87ac142007-07-06 22:36:17 +000098<ol>
99 <li><em>Manifest headers</em> - Any instruction that starts with
100a capital letter will appear in the resulting bundle's manifest file;
101the value for the header will either be copied, augmented, or generated
102by BND depending on the instruction.</li>
103 <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>
104 <li><em>Directives</em>
105- Any instruction starting with a '-' character is considered to be a
106directive that informs BND to perform some special processing and is
107not copied to the manifest.</li>
108</ol>
109
110
111<p>The remainder of this section covers the most important aspects of BND's instructions; for complete details refer to the <span class="nobr"><a href="http://www.aqute.biz/Code/Bnd" title="Visit page outside Confluence" rel="nofollow">BND documentation<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span>.</p>
112
113<p><a name="MavenBundlePlugin(BND)-instructions"></a></p>
114
115<h2><a name="MavenBundlePlugin(BND)-Instructions"></a>Instructions</h2>
116
Karl Paulsf87ac142007-07-06 22:36:17 +0000117<h3><a name="MavenBundlePlugin(BND)-{{&lt;ExportPackage&gt;}}"></a><tt>&lt;Export-Package&gt;</tt></h3>
118
119<p>The <tt>&lt;Export-Package&gt;</tt> instruction is a list of
120packages for the bundle to export. These packages are copied into the
121resulting bundle JAR file from the available classes (i.e., project
122classes, dependencies, and class path); thus, it is possible to include
123classes into your bundle that are not associated with source files in
124your project. <tt>&lt;Export-Package&gt;</tt> can be specified with
125package patterns using the '*' wildcard. Also, it is possible to
126exclude packages using negation by starting the package pattern with
127'!'. Thus, non-negated patterns indicate which of the available
128packages to include in the bundle, whereas negated patterns indicate
129which should not be included in the bundle.</p>
130
131<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>
132
133<p>Following standard OSGi R4 syntax, package patterns can include both
134directives and attributes, which will be copied appropriately into the
135generated Export-Package manifest header. Besides explicitly listing
136package version attributes, BND will also determine package versions by
137examining the source JAR file or from <tt>packageinfo</tt> files in the package directory.</p>
138
139<h3><a name="MavenBundlePlugin(BND)-{{&lt;PrivatePackage&gt;}}"></a><tt>&lt;Private-Package&gt;</tt></h3>
140
141<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>
142be exported by the bundle. If a package is selected by both the export
143and private package headers, then the export takes precedence.</p>
144
145<h3><a name="MavenBundlePlugin(BND)-{{&lt;IncludeResource&gt;}}"></a><tt>&lt;Include-Resource&gt;</tt></h3>
146
147<p>The <tt>&lt;Include-Resource&gt;</tt> instruction is a list of
148arbitrary resources that should be copied into the bundle JAR file. The
149specified resources are declared as clauses that can have the following
150forms:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000151
Karl Paulsf87ac142007-07-06 22:36:17 +0000152<div class="preformatted"><div class="preformattedContent">
153<pre>clause ::= assignment | inline | simple
154assignment ::= PATH '=' PATH
155simple ::= PATH
156inline ::= '@' PATH
157</pre>
158</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000159
Karl Paulsf87ac142007-07-06 22:36:17 +0000160<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>
161form will place the resource in the bundle JAR with only the file name,
162i.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>
163points to a directory, the entire directory hierarchy is copied into
164the resulting bundle JAR file relative to the specified directory. If a
165specific resource must be placed into a subdirectory of the bundle jar,
166then use the <tt>assignment</tt> form, where the first path is the the
167destination path (including file name if the resource is a file) and
168the 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>
169
170<p>If a resource clause is specified inside of "{ ... }" brackets, then
171variable substitution will be performed on the resource, where
172variables in the resources are denoted with "${ ... }" syntax.</p>
173
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000174<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>
175
Karl Paulsf87ac142007-07-06 22:36:17 +0000176<h3><a name="MavenBundlePlugin(BND)-{{&lt;ImportPackage&gt;}}"></a><tt>&lt;Import-Package&gt;</tt></h3>
177
178<p>The <tt>&lt;Import-Package&gt;</tt> instruction is a list of
179packages that are required by the bundle's contained packages. The
180default for this header is "*", resulting in importing all referred
181packages. This header rarely has to be explicitly specified. However,
182in certain cases when there is an unwanted import, such an import can
183be removed by using a negation package pattern. The package patterns
184work 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>
185
186<p><a name="MavenBundlePlugin(BND)-defaultbehavior"></a></p>
187
188<h2><a name="MavenBundlePlugin(BND)-DefaultBehavior"></a>Default Behavior</h2>
189
190<p>To use this plugin, very little information is required by BND. As
191part of the Maven integration, the plugin tries to set reasonable
192defaults for various instructions. For example:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000193
Karl Paulsf87ac142007-07-06 22:36:17 +0000194<ul>
195 <li><tt>&lt;Bundle-SymbolicName&gt;</tt> is assumed to be "<tt>${groupId}.${artifactId</tt>}".</li>
196 <li><tt>&lt;Export-Package&gt;</tt> is assumed to be "<tt>${groupId}.${artifactId}.*</tt>", unless <tt>&lt;Private-Package&gt;</tt> is specified, then <tt>&lt;Export-Package&gt;</tt> is assumed to be empty.</li>
197 <li><tt>&lt;Private-Package&gt;</tt> is assumed to be empty by default.</li>
198 <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.</li>
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000199 <li><tt>&lt;Include-Resource&gt;</tt> is generated from the project's Maven resources, typically "<tt>src/main/resources/</tt>",
Karl Paulsf87ac142007-07-06 22:36:17 +0000200which will copy the specified project directory hierarchy into the
201resulting bundle JAR file, mirroring standard Maven behavior.</li>
202 <li><tt>&lt;Bundle-Version&gt;</tt> is assumed to be "<tt>${pom.version</tt>}" with '-' character separator of the qualifier replaced with a '.' character.</li>
203 <li><tt>&lt;Bundle-Name&gt;</tt> is assumed to be "<tt>${pom.name</tt>}".</li>
204 <li><tt>&lt;Bundle-Description&gt;</tt> is assumed to be "<tt>${pom.description</tt>}".</li>
205 <li><tt>&lt;Bundle-License&gt;</tt> is assumed to be "<tt>${pom.licenses</tt>}".</li>
206 <li><tt>&lt;Bundle-Vendor&gt;</tt> is assumed to be "<tt>${pom.organization.name</tt>}".</li>
207 <li><tt>&lt;Bundle-DocURL&gt;</tt> is assumed to be "<tt>${pom.organization.url</tt>}".</li>
208</ul>
209
210
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000211<p>Since the plugin creates bundles for OSGi R4, it hard-codes <tt>Bundle-ManifestVersion</tt>
Karl Paulsf87ac142007-07-06 22:36:17 +0000212to be '2'. Additionally, it generates imports for every export to
213ensure package substitutability, which is very important when working
214with collaborating services. It is possible to override any of these
215values (except <tt>Bundle-ManifestVersion</tt>) just by specifying the desired value in the plugin configuration section of the POM file.</p>
216
217<p><a name="MavenBundlePlugin(BND)-howto"></a></p>
218
219<h1><a name="MavenBundlePlugin(BND)-Detailed&quot;HowTo&quot;"></a>Detailed "How To"</h1>
220
221<h2><a name="MavenBundlePlugin(BND)-GetMaven2"></a>Get Maven2</h2>
222
223<p>The first step in the process of using the plugin is downloading and
224installing the latest version of the Maven2 runtime. The latest Maven2
225release and instuctions for getting started with Maven2 can be found at
226the <span class="nobr"><a href="http://maven.apache.org/index.html" title="Visit page outside Confluence" rel="nofollow">Maven website<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span>.</p>
227
228<h2><a name="MavenBundlePlugin(BND)-UsingthePlugin"></a>Using the Plugin</h2>
229
230<p>To use the maven-bundle-plugin, you first need to add the plugin and
231some appropriate plugin configuration to your bundle project's POM.
232Below is an example of a simple OSGi bundle POM for Maven2:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000233
Karl Paulsf87ac142007-07-06 22:36:17 +0000234<div class="preformatted"><div class="preformattedContent">
235<pre>&lt;project&gt;
236 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
237 &lt;groupId&gt;my-osgi-bundles&lt;/groupId&gt;
238 &lt;artifactId&gt;examplebundle&lt;/artifactId&gt;
239 &lt;packaging&gt;bundle&lt;/packaging&gt; &lt;!-- (1) --&gt;
240 &lt;version&gt;1.0&lt;/version&gt;
241 &lt;name&gt;Example Bundle&lt;/name&gt;
242 &lt;dependencies&gt;
243 &lt;dependency&gt;
244 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
245 &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000246 &lt;version&gt;1.0.0&lt;/version&gt;
Karl Paulsf87ac142007-07-06 22:36:17 +0000247 &lt;/dependency&gt;
248 &lt;/dependencies&gt;
249 &lt;build&gt;
250 &lt;plugins&gt;
251 &lt;plugin&gt; &lt;!-- (2) START --&gt;
252 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
253 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
254 &lt;extensions&gt;true&lt;/extensions&gt;
255 &lt;configuration&gt;
256 &lt;instructions&gt;
257 &lt;Export-Package&gt;com.my.company.api&lt;/Export-Package&gt;
258 &lt;Private-Package&gt;com.my.company.*&lt;/Private-Package&gt;
259 &lt;Bundle-Activator&gt;com.my.company.Activator&lt;/Bundle-Activator&gt;
260 &lt;/instructions&gt;
261 &lt;/configuration&gt;
262 &lt;/plugin&gt; &lt;!-- (2) END --&gt;
263 &lt;/plugins&gt;
264 &lt;/build&gt;
Karl Paulsf87ac142007-07-06 22:36:17 +0000265&lt;/project&gt;
266</pre>
267</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000268
269<p>There are two main things to note: (1) the <tt>&lt;packaging&gt;</tt>
270specifier must be "bundle" and (2) the plugin and configuration must be
Karl Paulsf87ac142007-07-06 22:36:17 +0000271specified (the configuration section is where you will issue
Stuart McCulloch93de6492007-12-16 15:59:05 +0000272instructions to the plugin).</p>
Karl Paulsf87ac142007-07-06 22:36:17 +0000273
274<h2><a name="MavenBundlePlugin(BND)-RealWorldExample"></a>Real-World Example</h2>
275
276<p>Consider this more real-world example using Felix' Log Service
277implementation. The Log Service project is comprised of a single
278package: <tt>org.apache.felix.log.impl</tt>. It has a dependency on
279the core OSGi interfaces as well as a dependency on the compendium OSGi
280interfaces for the specific log service interfaces. The following is
281its POM file:</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000282
Karl Paulsf87ac142007-07-06 22:36:17 +0000283<div class="preformatted"><div class="preformattedContent">
284<pre>&lt;project&gt;
285 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
286 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
287 &lt;artifactId&gt;org.apache.felix.log&lt;/artifactId&gt;
288 &lt;packaging&gt;bundle&lt;/packaging&gt;
289 &lt;name&gt;Apache Felix Log Service&lt;/name&gt;
290 &lt;version&gt;0.8.0-SNAPSHOT&lt;/version&gt;
291 &lt;description&gt;
292 This bundle provides an implementation of the OSGi R4 Log service.
293 &lt;/description&gt;
294 &lt;dependencies&gt;
295 &lt;dependency&gt;
296 &lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
297 &lt;artifactId&gt;org.osgi.core&lt;/artifactId&gt;
298 &lt;version&gt;0.8.0-incubator&lt;/version&gt;
299 &lt;/dependency&gt;
300 &lt;dependency&gt;
301 &lt;groupId&gt;${pom.groupId}&lt;/groupId&gt;
302 &lt;artifactId&gt;org.osgi.compendium&lt;/artifactId&gt;
303 &lt;version&gt;0.9.0-incubator-SNAPSHOT&lt;/version&gt;
304 &lt;/dependency&gt;
305 &lt;/dependencies&gt;
306 &lt;build&gt;
307 &lt;plugins&gt;
308 &lt;plugin&gt;
309 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
310 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
311 &lt;extensions&gt;true&lt;/extensions&gt;
312 &lt;configuration&gt;
313 &lt;instructions&gt;
314 &lt;Export-Package&gt;org.osgi.service.log&lt;/Export-Package&gt;
315 &lt;Private-Package&gt;org.apache.felix.log.impl&lt;/Private-Package&gt;
316 &lt;Bundle-SymbolicName&gt;${pom.artifactId}&lt;/Bundle-SymbolicName&gt;
317 &lt;Bundle-Activator&gt;${pom.artifactId}.impl.Activator&lt;/Bundle-Activator&gt;
318 &lt;Export-Service&gt;org.osgi.service.log.LogService,org.osgi.service.log.LogReaderService&lt;/Export-Service&gt;
319 &lt;/instructions&gt;
320 &lt;/configuration&gt;
321 &lt;/plugin&gt;
322 &lt;/plugins&gt;
323 &lt;/build&gt;
Karl Paulsf87ac142007-07-06 22:36:17 +0000324&lt;/project&gt;
325</pre>
326</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000327
Karl Paulsf87ac142007-07-06 22:36:17 +0000328<p>Notice that the <tt>&lt;Export-Package&gt;</tt> instruction
329specifies that the bundle exports the Log Service package, even though
330this package is not contained in the bundle project. By declaring this,
331the plugin will copy the Log Service package into the resulting bundle
332JAR file. This is useful in this case because now the bundle can
333resolve without having to download the entire compendium bundle. The
334resulting manifest for the Log Service bundle looks like this (notice
335how the imports/exports automatically have version information
336associated with them, which was obtained from packageinfo files in the
337source packages):</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000338
Karl Paulsf87ac142007-07-06 22:36:17 +0000339<div class="preformatted"><div class="preformattedContent">
340<pre>Manifest-Version: 1
341Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
342Bundle-Activator: org.apache.felix.log.impl.Activator
343Import-Package: org.osgi.framework;version=1.3, org.osgi.service.log;v
344 ersion=1.3
345Include-Resource: src/main/resources
346Export-Package: org.osgi.service.log;uses:=org.osgi.framework;version=
347 1.3
348Bundle-Version: 0.8.0.SNAPSHOT
349Bundle-Name: Apache Felix Log Service
350Bundle-Description: This bundle provides an implementation of the OSGi
351 R4 Log service.
352Private-Package: org.apache.felix.log.impl
353Bundle-ManifestVersion: 2
354Export-Service: org.osgi.service.log.LogService,org.osgi.service.log.L
355 ogReaderService
356Bundle-SymbolicName: org.apache.felix.log
357</pre>
358</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000359
Karl Paulsf87ac142007-07-06 22:36:17 +0000360<p>The resulting bundle JAR file has the following content (notice how
361the 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 +0000362
Karl Paulsf87ac142007-07-06 22:36:17 +0000363<div class="preformatted"><div class="preformattedContent">
364<pre>META-INF/MANIFEST.MF
365LICENSE
366META-INF/
367META-INF/maven/
368META-INF/maven/org.apache.felix/
369META-INF/maven/org.apache.felix/org.apache.felix.log/
370META-INF/maven/org.apache.felix/org.apache.felix.log/pom.properties
371META-INF/maven/org.apache.felix/org.apache.felix.log/pom.xml
372NOTICE
373org/
374org/apache/
375org/apache/felix/
376org/apache/felix/log/
377org/apache/felix/log/impl/
378org/apache/felix/log/impl/Activator.class
379org/apache/felix/log/impl/Log.class
380org/apache/felix/log/impl/LogEntryImpl.class
381org/apache/felix/log/impl/LogException.class
382org/apache/felix/log/impl/LogListenerThread.class
383org/apache/felix/log/impl/LogNode.class
384org/apache/felix/log/impl/LogNodeEnumeration.class
385org/apache/felix/log/impl/LogReaderServiceFactory.class
386org/apache/felix/log/impl/LogReaderServiceImpl.class
387org/apache/felix/log/impl/LogServiceFactory.class
388org/apache/felix/log/impl/LogServiceImpl.class
389org/osgi/
390org/osgi/service/
391org/osgi/service/log/
392org/osgi/service/log/LogEntry.class
393org/osgi/service/log/LogListener.class
394org/osgi/service/log/LogReaderService.class
395org/osgi/service/log/LogService.class
396org/osgi/service/log/package.html
397org/osgi/service/log/packageinfo
398</pre>
399</div></div>
400
401<h2><a name="MavenBundlePlugin(BND)-BuildingthePlugin"></a>Building the Plugin</h2>
402
Stuart McCulloch93de6492007-12-16 15:59:05 +0000403<p>The plugin is hosted at the Apache Felix project. The following
404steps describe how to build and install the plugin into your local
405Maven2 repository.</p>
Karl Paulsf87ac142007-07-06 22:36:17 +0000406
407<p>Using the SVN client of your choice, checkout the maven-bundle-plugin project.</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000408
Karl Paulsf87ac142007-07-06 22:36:17 +0000409<div class="preformatted"><div class="preformattedContent">
Stuart McCulloch93de6492007-12-16 15:59:05 +0000410<pre>$ svn co http://svn.apache.org/repos/asf/felix/trunk/bundleplugin
Karl Paulsf87ac142007-07-06 22:36:17 +0000411</pre>
412</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000413
Karl Paulsf87ac142007-07-06 22:36:17 +0000414<p>Using Maven2, build and install the maven-bundle-plugin by issuing
415the following Maven2 command in the project directory that was created
416as a result of the previous step.</p>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000417
Karl Paulsf87ac142007-07-06 22:36:17 +0000418<div class="preformatted"><div class="preformattedContent">
419<pre>$ mvn install
420</pre>
421</div></div>
Stuart McCulloch93de6492007-12-16 15:59:05 +0000422
423<h1><a name="MavenBundlePlugin(BND)-Goals"></a>Goals</h1>
424
425<p>The maven-bundle-plugin also provides additional functionality via
426some Maven goals. Command-line execution of a goal is performed as
427follows:</p>
428
429<div class="preformatted"><div class="preformattedContent">
430<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>
437 <li><tt>bundle</tt> - build an OSGi bundle jar<br>
438configuration options:
439 <ul>
440 <li><tt>manifestLocation</tt> defaults to ${project.build.outputDirectory}/META-INF</li>
441 <li><tt>unpackBundle</tt> unpack bundle contents to output directory, defaults to false</li>
442 <li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
443 </ul>
444 </li>
445 <li><tt>bundleall</tt> - build an OSGi bundle jar for all transitive dependencies<br>
446configuration options:
447 <ul>
448 <li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
449 </ul>
450 </li>
451 <li><tt>wrap</tt> - as above, but limited to the first level of dependencies<br>
452configuration options:
453 <ul>
454 <li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
455 </ul>
456 </li>
457 <li><tt>manifest</tt> - create an OSGi manifest for the current project<br>
458configuration options:
459 <ul>
460 <li><tt>manifestLocation</tt> defaults to ${project.build.outputDirectory}/META-INF</li>
461 <li><tt>supportedProjectTypes</tt> defaults to "jar","bundle"</li>
462 </ul>
463 </li>
464</ul>
465
466
467<p>There are also new instructions available from the underlying BND
468tool, which continues to be improved independently; for the latest see <span class="nobr"><a href="http://aqute.biz/Code/Bnd" title="Visit page outside Confluence" rel="nofollow">BND documentation<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span>.</p>
469
470<p>The default goal <tt>bundle</tt> will be initialized by setting the &lt;packaging&gt; entry to "bundle".</p>
471
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000472<h1><a name="MavenBundlePlugin(BND)-Thefollowingfeaturesareonlyavailableinthe1.1.0SNAPSHOTversion"></a>The following features are only available in the 1.1.0-SNAPSHOT version</h1>
473
Stuart McCulloch93de6492007-12-16 15:59:05 +0000474<h1><a name="MavenBundlePlugin(BND)-Embeddingdependencies"></a>Embedding dependencies</h1>
475
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000476<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 +0000477
478<div class="code"><div class="codeContent">
479<pre class="code-xml"><span class="code-tag">&lt;Embed-Dependency&gt;</span>dependencies<span class="code-tag">&lt;/Embed-Dependency&gt;</span></pre>
480</div></div>
481
482<p>where:</p>
483
484<div class="preformatted"><div class="preformattedContent">
485<pre>dependencies ::= clause ( ',' clause ) *
486clause ::= MATCH ( ';' attr '=' MATCH | ';inline=true' )
487attr ::= 'groupId' | 'artifactId' | 'version' | 'scope' | 'type' | 'classifier'
488MATCH ::= &lt;globbed regular expressions&gt;
489</pre>
490</div></div>
491
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000492<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.</p>
493
Stuart McCulloch93de6492007-12-16 15:59:05 +0000494<p>some examples:</p>
495
496<div class="code"><div class="codeContent">
497<pre class="code-xml"><span class="code-tag">&lt;Embed-Dependency&gt;</span>*;scope=compile|runtime<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
498
499<span class="code-tag">&lt;Embed-Dependency&gt;</span>junit;scope=test<span class="code-tag">&lt;/Embed-Dependency&gt;</span>
500
501<span class="code-tag">&lt;Embed-Dependency&gt;</span>aopalliance;scope=!test;inline=true<span class="code-tag">&lt;/Embed-Dependency&gt;</span></pre>
502</div></div>
503
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000504<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 +0000505
506<ul>
507 <li><tt>&lt;Embed-StripVersion&gt;true&lt;/Embed-StripVersion&gt;</tt> - removes the version from the file (ie. <em>artifactId.jar</em>)</li>
508 <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>
509 <li><tt>&lt;Embed-Directory&gt;directory&lt;/Embed-Directory&gt;</tt> - adds a subdirectory (ie. <em>directory/artifactId-version.jar</em>)</li>
510</ul>
511
512
513<p>Normally the plugin only checks direct dependencies, but this can be
514changed to include the complete set of transitive dependencies with the
515following option:</p>
516
517<div class="code"><div class="codeContent">
518<pre class="code-xml"><span class="code-tag">&lt;Embed-Transitive&gt;</span>true<span class="code-tag">&lt;/Embed-Transitive&gt;</span></pre>
519</div></div>
520
521<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>
522
523<div class="code"><div class="codeContent">
524<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>
525</div></div>
526
Stuart McCulloch7c961f52008-01-02 08:56:07 +0000527<h2><a name="MavenBundlePlugin(BND)-EmbedDependencyandExportPackage"></a>Embed-Dependency and Export-Package</h2>
528
529<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>
530instructions will result in classes being inlined in the bundle, even
531though they also exist inside the embedded jar. If you want to export
532packages from an embedded dependency without such duplication then you
533can either inline the dependency, or use a new BND instruction called <tt>&lt;_exportcontents&gt;</tt>.</p>
534
535<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 +0000536
537<h1><a name="MavenBundlePlugin(BND)-OBRintegration"></a>OBR integration</h1>
538
539<p>The latest Maven Bundle Plugin automatically updates the local OBR
540repository.xml file during the install phase, using a default location
541of:</p>
542
543<div class="code"><div class="codeContent">
544<pre class="code-java">&lt;LOCAL-MAVEN-REPOSITORY&gt;/repository.xml</pre>
545</div></div>
546
547<p>You can configure the location of the OBR repository by using the command line:</p>
548
549<div class="code"><div class="codeContent">
550<pre class="code-java">mvn clean install -DobrRepository=&lt;PATH_TO_OBR&gt;</pre>
551</div></div>
552
553<p>or in the configuration section for the maven-bundle-plugin in your Maven POM:</p>
554
555<div class="code"><div class="codeContent">
556<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
557<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
558<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
559<span class="code-tag">&lt;configuration&gt;</span>
560 <span class="code-tag">&lt;obrRepository&gt;</span>PATH_TO_OBR<span class="code-tag">&lt;/obrRepository&gt;</span>
561 <span class="code-tag">&lt;instructions&gt;</span>
562 <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
563 <span class="code-tag">&lt;/instructions&gt;</span>
564<span class="code-tag">&lt;/configuration&gt;</span></pre>
565</div></div>
566
567<p>to disable OBR installation set the obrRepository to NONE, for example:</p>
568
569<div class="code"><div class="codeContent">
570<pre class="code-xml"><span class="code-tag">&lt;groupId&gt;</span>org.apache.felix<span class="code-tag">&lt;/groupId&gt;</span>
571<span class="code-tag">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="code-tag">&lt;/artifactId&gt;</span>
572<span class="code-tag">&lt;extensions&gt;</span>true<span class="code-tag">&lt;/extensions&gt;</span>
573<span class="code-tag">&lt;configuration&gt;</span>
574 <span class="code-tag">&lt;obrRepository&gt;</span>NONE<span class="code-tag">&lt;/obrRepository&gt;</span>
575 <span class="code-tag">&lt;instructions&gt;</span>
576 <span class="code-tag"><span class="code-comment">&lt;!-- bnd instructions --&gt;</span></span>
577 <span class="code-tag">&lt;/instructions&gt;</span>
578<span class="code-tag">&lt;/configuration&gt;</span></pre>
579</div></div>
580
581
582<h1><a name="MavenBundlePlugin(BND)-Eclipse/PDEintegration"></a>Eclipse/PDE integration</h1>
583
584<p>It is possible to configure the Maven Bundle Plugin to put the
585bundle manifest where Eclipse/PDE expects it, and use the Maven
586Dependency Plugin to arrange for any embedded dependencies to appear in
587a local directory that matches the Bundle-ClassPath entries. Here is an
588example POM that does this:</p>
589
590<div class="preformatted"><div class="preformattedContent">
591<pre>&lt;project&gt;
592
593 &lt;properties&gt;
594 &lt;bundle.symbolicName&gt;org.example&lt;/bundle.symbolicName&gt;
595 &lt;bundle.namespace&gt;org.example&lt;/bundle.namespace&gt;
596 &lt;/properties&gt;
597
598 &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
599 &lt;groupId&gt;examples&lt;/groupId&gt;
600 &lt;artifactId&gt;org.example&lt;/artifactId&gt;
601 &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
602
603 &lt;name&gt;${bundle.symbolicName} [${bundle.namespace}]&lt;/name&gt;
604
605 &lt;packaging&gt;bundle&lt;/packaging&gt;
606
607 &lt;build&gt;
608 &lt;plugins&gt;
609 &lt;plugin&gt;
610 &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
611 &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
612 &lt;version&gt;1.1.0-SNAPSHOT&lt;/version&gt;
613 &lt;extensions&gt;true&lt;/extensions&gt;
614 &lt;!--
615 the following instructions build a simple set of public/private classes into an OSGi bundle
616 --&gt;
617 &lt;configuration&gt;
618 &lt;manifestLocation&gt;META-INF&lt;/manifestLocation&gt;
619 &lt;instructions&gt;
620 &lt;Bundle-SymbolicName&gt;${bundle.symbolicName}&lt;/Bundle-SymbolicName&gt;
621 &lt;Bundle-Version&gt;${pom.version}&lt;/Bundle-Version&gt;
622 &lt;!--
623 assume public classes are in the top package, and private classes are under ".internal"
624 --&gt;
625 &lt;Export-Package&gt;${bundle.namespace};version="${pom.version}"&lt;/Export-Package&gt;
626 &lt;Private-Package&gt;${bundle.namespace}.internal&lt;/Private-Package&gt;
627 &lt;Bundle-Activator&gt;${bundle.namespace}.internal.Activator&lt;/Bundle-Activator&gt;
628 &lt;!--
629 embed compile/runtime dependencies using path that matches the copied dependency folder
630 --&gt;
631 &lt;Embed-Dependency&gt;*;scope=compile|runtime;inline=false&lt;/Embed-Dependency&gt;
632 &lt;Embed-Directory&gt;target/dependency&lt;/Embed-Directory&gt;
633 &lt;Embed-StripGroup&gt;true&lt;/Embed-StripGroup&gt;
634 &lt;/instructions&gt;
635 &lt;/configuration&gt;
636 &lt;/plugin&gt;
637 &lt;plugin&gt;
638 &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
639 &lt;executions&gt;
640 &lt;execution&gt;
641 &lt;id&gt;copy-dependencies&lt;/id&gt;
642 &lt;phase&gt;package&lt;/phase&gt;
643 &lt;goals&gt;
644 &lt;goal&gt;copy-dependencies&lt;/goal&gt;
645 &lt;/goals&gt;
646 &lt;/execution&gt;
647 &lt;/executions&gt;
648 &lt;/plugin&gt;
649 &lt;/plugins&gt;
650 &lt;/build&gt;
651
652 &lt;dependencies&gt;
653 &lt;dependency&gt;
654 &lt;groupId&gt;org.osgi&lt;/groupId&gt;
655 &lt;artifactId&gt;osgi_R4_core&lt;/artifactId&gt;
656 &lt;version&gt;1.0&lt;/version&gt;
657 &lt;scope&gt;provided&lt;/scope&gt;
658 &lt;optional&gt;true&lt;/optional&gt;
659 &lt;/dependency&gt;
660 &lt;dependency&gt;
661 &lt;groupId&gt;org.osgi&lt;/groupId&gt;
662 &lt;artifactId&gt;osgi_R4_compendium&lt;/artifactId&gt;
663 &lt;version&gt;1.0&lt;/version&gt;
664 &lt;scope&gt;provided&lt;/scope&gt;
665 &lt;optional&gt;true&lt;/optional&gt;
666 &lt;/dependency&gt;
667 &lt;dependency&gt;
668 &lt;groupId&gt;junit&lt;/groupId&gt;
669 &lt;artifactId&gt;junit&lt;/artifactId&gt;
670 &lt;version&gt;3.8.1&lt;/version&gt;
671 &lt;scope&gt;compile&lt;/scope&gt;
672 &lt;optional&gt;true&lt;/optional&gt;
673 &lt;/dependency&gt;
674 &lt;/dependencies&gt;
675
676&lt;/project&gt;
677</pre>
678</div></div>
679
680<p>To generate the Eclipse metadata use:</p>
681
682<div class="code"><div class="codeContent">
683<pre class="code-java">mvn clean <span class="code-keyword">package</span> eclipse:eclipse -Declipse.pde install</pre>
684</div></div>
685
686<p>and you should now be able to import this as an existing Eclipse project.</p>
687
688<p>FYI: the above POM was generated using the <tt>pax-create-bundle</tt> command from <span class="nobr"><a href="http://www.ops4j.org/projects/pax/construct/index.html" title="Visit page outside Confluence" rel="nofollow">Pax-Construct<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/linkext7.gif" alt="" align="absmiddle" border="0" height="7" width="7"></sup></a></span> and then tweaked to demonstrate using the Maven Dependency Plugin to handle embedded jars in Eclipse.</p>
689
690<p>With the original Pax-Construct generated POM you would simply use:</p>
691
692<div class="code"><div class="codeContent">
693<pre class="code-java">mvn clean <span class="code-keyword">package</span> pax:eclipse</pre>
694</div></div>
695
696<p>to create the appropriate Eclipse files and manifest, and also
697handle any embedded entries. The pax:eclipse goal extends
698eclipse:eclipse, and supports the same parameters.</p>
699
700<h1><a name="MavenBundlePlugin(BND)-Unpackingbundlecontentsto'target/classes'"></a>Unpacking bundle contents to 'target/classes'</h1>
701
702<p>Once in a while you may create a bundle which contains additional classes to the ones compiled from <tt>src/main/java</tt>,
703for example when you embed the classes from another jar. This can
704sometimes cause unforeseen problems in Maven, as it will use the output
705directory (<tt>target/classes</tt>) rather than the final bundle, when compiling against projects in the same reactor (ie. the same build).</p>
706
707<p>The easiest way to get around this Maven 'feature' is to unpack the
708contents of the bundle to the output directory after the packaging
709step, so the additional classes will be found where Maven expects them.
710Thankfully there is now an easy option to do this in the bundle-plugin:</p>
711
712<div class="code"><div class="codeContent">
713<pre class="code-java">&lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
714&lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
715&lt;extensions&gt;<span class="code-keyword">true</span>&lt;/extensions&gt;
716&lt;configuration&gt;
717 &lt;unpackBundle&gt;<span class="code-keyword">true</span>&lt;/unpackBundle&gt;
718 &lt;instructions&gt;
719 &lt;!-- bnd instructions --&gt;
720 &lt;/instructions&gt;
721&lt;/configuration&gt;</pre>
722</div></div>
723
724<h1><a name="MavenBundlePlugin(BND)-UsinganexistingMANIFEST.MFfile"></a>Using an existing MANIFEST.MF file</h1>
725
726<p>If you have an existing manifest, you can add this to the Bnd instructions, like so:</p>
727
728<div class="code"><div class="codeContent">
729<pre class="code-java">&lt;_include&gt;src/main/resources/META-INF/MANIFEST.MF&lt;/_include&gt;
730&lt;Export-Package&gt;org.example.*&lt;/Export-Package&gt;</pre>
731</div></div>
732
733<p>Bnd will use it when calculating the bundle contents, and will also
734copy across all manifest attributes starting with a capital letter.<br>
735As shown in the above example, you could use this to include a non-OSGi
736manifest which you then customize with extra OSGi attributes.</p>
737
738<h1><a name="MavenBundlePlugin(BND)-Feedback"></a>Feedback</h1>
739
740<p>Subscribe to the Felix users mailing list by sending a message to <span class="nobr"><a href="mailto:users-subscribe@felix.apache.org" title="Send mail to users-subscribe@felix.apache.org" rel="nofollow">users-subscribe@felix.apache.org<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/mail_small.gif" alt="" align="absmiddle" border="0" height="12" width="13"></sup></a></span>; after subscribing, email questions or feedback to <span class="nobr"><a href="mailto:users@felix.apache.org" title="Send mail to users@felix.apache.org" rel="nofollow">users@felix.apache.org<sup><img class="rendericon" src="maven-bundle-plugin-bnd_files/mail_small.gif" alt="" align="absmiddle" border="0" height="12" width="13"></sup></a></span>.</p>
Karl Paulsf87ac142007-07-06 22:36:17 +0000741 </div>
742
Stuart McCulloch93de6492007-12-16 15:59:05 +0000743</body></html>