blob: a242c40e5ee0b02ba93ce31e45a90311063ede6e [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Apache Felix - Creating Bundles Using BND</title>
<link rel="icon" href="/res/favicon.ico">
<link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
<link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
<div class="title">
<div class="logo">
<a href="https://felix.apache.org/">
<img border="0" alt="Apache Felix" src="/res/logo.png">
</a>
</div>
<div class="header">
<a href="https://www.apache.org/">
<img border="0" alt="Apache" src="/res/apache.png">
</a>
</div>
</div>
<div class="menu">
<style type="text/css">
/* The following code is added by mdx_elementid.py
It was originally lifted from http://subversion.apache.org/style/site.css */
/*
* Hide class="elementid-permalink", except when an enclosing heading
* has the :hover property.
*/
.headerlink, .elementid-permalink {
visibility: hidden;
}
h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
<p><a href="/news.html">News</a> <br />
<a href="/license.html">License</a> <br />
<a href="/downloads.cgi">Downloads</a> <br />
<a href="/documentation.html">Documentation</a> <br />
<a href="/documentation/community/project-info.html">Project Info</a> <br />
<a href="/documentation/community/contributing.html">Contributing</a> <br />
<a href="/sitemap.html">Site Map</a> <br />
<a href="https://www.apache.org/">ASF</a> <br />
<a href="https://www.apache.org/security/">Security</a> <br />
<a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a> <br />
<a href="https://www.apache.org/foundation/thanks.html">Sponsors</a> </p>
<iframe
src="https://www.apache.org/ads/button.html"
style="border-width:0; float: left"
frameborder="0"
scrolling="no"
width="135"
height="135">
</iframe>
</div>
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
<a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/apache-felix-commons.html">Apache Felix Commons</a>
</div>
<h1>Creating Bundles Using BND</h1>
<style type="text/css">
/* The following code is added by mdx_elementid.py
It was originally lifted from http://subversion.apache.org/style/site.css */
/*
* Hide class="elementid-permalink", except when an enclosing heading
* has the :hover property.
*/
.headerlink, .elementid-permalink {
visibility: hidden;
}
h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
<h5 id="purpose">Purpose<a class="headerlink" href="#purpose" title="Permanent link">&para;</a></h5>
<p>Provide the list of steps required to create a library bundle by wrapping the library jar using bnd (http://bnd.bndtools.org/).</p>
<h5 id="steps">Steps<a class="headerlink" href="#steps" title="Permanent link">&para;</a></h5>
<ol>
<li>Use bnd to analyze the library jar (e.g., java -jar bnd-0.0.jar print path/to/FOO.jar) </li>
<li>At the bottom of the bnd output, look for "Unresolved references to ..." which identify package dependencies. If found,
a. Identifiy the library jars that provide the missing packages
b. Recursively use this process on each dependency </li>
<li>Create a directory that will be the project directory for the bundle (e.g., mkdir FOO-osgi) </li>
<li>Copy the template pom.xml file to the bundle's project directory </li>
<li>Edit the pom.xml file to tailor it for the library jar. Specifically,
a. change artifactId
b. verify description
c. change version
d. change FOO's library jar dependency (groupId, artifactId)
e. add any other dependencies (from step 2b)
f. change Export-Package
g. change Private-Package or delete it if it's not needed
h. All packages listed in step 1 should be in either Export-Package or Private-Package. Use the library's javadoc to identify the exported packages. The remaining packages should be private.</li>
<li>Run "mvn package" to in the project directory to create the bundle </li>
<li>Use bnd to verify the bundle's contents (e.g., java -jar bnd-0.0.jar print target/FOO-osgi-VERSION.jar) </li>
<li>Run "mvn install" to install the bundle in the local repository</li>
</ol>
<h5 id="example-pom">Example POM<a class="headerlink" href="#example-pom" title="Permanent link">&para;</a></h5>
<div class="codehilite"><pre><span class="nt">&lt;project</span>
<span class="na">xmlns=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0&quot;</span>
<span class="na">xmlns:xsi=</span><span class="s">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
<span class="na">xsi:schemaLocation=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span class="nt">&gt;</span>
<span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>
<span class="nt">&lt;groupId&gt;</span>org.apache.felix.commons<span class="nt">&lt;/groupId&gt;</span>
<span class="nt">&lt;artifactId&gt;</span>FOO-osgi<span class="nt">&lt;/artifactId&gt;</span>
<span class="nt">&lt;name&gt;</span><span class="cp">${</span><span class="n">pom</span><span class="o">.</span><span class="n">artifactId</span><span class="cp">}</span> bundle<span class="nt">&lt;/name&gt;</span>
<span class="nt">&lt;description&gt;</span>
This bundle simply wraps FOO-<span class="cp">${</span><span class="n">pom</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span>.jar.
<span class="nt">&lt;/description&gt;</span>
<span class="nt">&lt;version&gt;</span>X.Y<span class="nt">&lt;/version&gt;</span>
<span class="nt">&lt;packaging&gt;</span>bundle<span class="nt">&lt;/packaging&gt;</span>
<span class="nt">&lt;organization&gt;</span>
<span class="nt">&lt;name&gt;</span>Apache Felix Project<span class="nt">&lt;/name&gt;</span>
<span class="nt">&lt;url&gt;</span>http://felix.apache.org/<span class="nt">&lt;/url&gt;</span>
<span class="nt">&lt;/organization&gt;</span>
<span class="nt">&lt;dependencies&gt;</span>
<span class="nt">&lt;dependency&gt;</span>
<span class="nt">&lt;groupId&gt;</span>FOO<span class="nt">&lt;/groupId&gt;</span>
<span class="nt">&lt;artifactId&gt;</span>FOO<span class="nt">&lt;/artifactId&gt;</span>
<span class="nt">&lt;version&gt;</span><span class="cp">${</span><span class="n">pom</span><span class="o">.</span><span class="n">version</span><span class="cp">}</span><span class="nt">&lt;/version&gt;</span>
<span class="nt">&lt;/dependency&gt;</span>
<span class="nt">&lt;/dependencies&gt;</span>
<span class="nt">&lt;build&gt;</span>
<span class="nt">&lt;plugins&gt;</span>
<span class="nt">&lt;plugin&gt;</span>
<span class="nt">&lt;groupId&gt;</span>org.apache.felix<span class="nt">&lt;/groupId&gt;</span>
<span class="nt">&lt;artifactId&gt;</span>maven-bundle-plugin<span class="nt">&lt;/artifactId&gt;</span>
<span class="nt">&lt;extensions&gt;</span>true<span class="nt">&lt;/extensions&gt;</span>
<span class="nt">&lt;configuration&gt;</span>
<span class="nt">&lt;instructions&gt;</span>
<span class="nt">&lt;Bundle</span><span class="err">-SymbolicName</span><span class="nt">&gt;</span><span class="cp">${</span><span class="n">pom</span><span class="o">.</span><span class="n">artifactId</span><span class="cp">}</span><span class="nt">&lt;/Bundle-SymbolicName&gt;</span>
<span class="nt">&lt;Export</span><span class="err">-Package</span><span class="nt">&gt;</span>FOO<span class="nt">&lt;/Export-Package&gt;</span>
<span class="nt">&lt;Private</span><span class="err">-Package</span><span class="nt">&gt;</span>FOO.impl<span class="nt">&lt;/Private-Package&gt;</span>
<span class="nt">&lt;/instructions&gt;</span>
<span class="nt">&lt;/configuration&gt;</span>
<span class="nt">&lt;/plugin&gt;</span>
<span class="nt">&lt;/plugins&gt;</span>
<span class="nt">&lt;/build&gt;</span>
<span class="nt">&lt;/project&gt;</span>
</pre></div>
<h5 id="resources">Resources<a class="headerlink" href="#resources" title="Permanent link">&para;</a></h5>
<p>Bnd - Bundle Tool
http://bnd.bndtools.org/</p>
<p>Bundle Plugin for Maven
http://felix.apache.org/site/maven-bundle-plugin-bnd.html</p>
<div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
Rev. 1762306 by cziegeler on Mon, 26 Sep 2016 09:54:12 +0000
</div>
<div class="trademarkFooter">
Apache 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.
</div>
</div>
</body>
</html>