| <!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> » <a href="/documentation.html">Documentation</a> » <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">¶</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">¶</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">¶</a></h5> |
| <div class="codehilite"><pre><span class="nt"><project</span> |
| <span class="na">xmlns=</span><span class="s">"http://maven.apache.org/POM/4.0.0"</span> |
| <span class="na">xmlns:xsi=</span><span class="s">"http://www.w3.org/2001/XMLSchema-instance"</span> |
| <span class="na">xsi:schemaLocation=</span><span class="s">"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"</span><span class="nt">></span> |
| |
| <span class="nt"><modelVersion></span>4.0.0<span class="nt"></modelVersion></span> |
| <span class="nt"><groupId></span>org.apache.felix.commons<span class="nt"></groupId></span> |
| <span class="nt"><artifactId></span>FOO-osgi<span class="nt"></artifactId></span> |
| <span class="nt"><name></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"></name></span> |
| <span class="nt"><description></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"></description></span> |
| <span class="nt"><version></span>X.Y<span class="nt"></version></span> |
| <span class="nt"><packaging></span>bundle<span class="nt"></packaging></span> |
| |
| <span class="nt"><organization></span> |
| <span class="nt"><name></span>Apache Felix Project<span class="nt"></name></span> |
| <span class="nt"><url></span>http://felix.apache.org/<span class="nt"></url></span> |
| <span class="nt"></organization></span> |
| |
| <span class="nt"><dependencies></span> |
| <span class="nt"><dependency></span> |
| <span class="nt"><groupId></span>FOO<span class="nt"></groupId></span> |
| <span class="nt"><artifactId></span>FOO<span class="nt"></artifactId></span> |
| <span class="nt"><version></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"></version></span> |
| <span class="nt"></dependency></span> |
| <span class="nt"></dependencies></span> |
| |
| <span class="nt"><build></span> |
| <span class="nt"><plugins></span> |
| <span class="nt"><plugin></span> |
| <span class="nt"><groupId></span>org.apache.felix<span class="nt"></groupId></span> |
| <span class="nt"><artifactId></span>maven-bundle-plugin<span class="nt"></artifactId></span> |
| <span class="nt"><extensions></span>true<span class="nt"></extensions></span> |
| <span class="nt"><configuration></span> |
| <span class="nt"><instructions></span> |
| <span class="nt"><Bundle</span><span class="err">-SymbolicName</span><span class="nt">></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"></Bundle-SymbolicName></span> |
| <span class="nt"><Export</span><span class="err">-Package</span><span class="nt">></span>FOO<span class="nt"></Export-Package></span> |
| <span class="nt"><Private</span><span class="err">-Package</span><span class="nt">></span>FOO.impl<span class="nt"></Private-Package></span> |
| <span class="nt"></instructions></span> |
| <span class="nt"></configuration></span> |
| <span class="nt"></plugin></span> |
| <span class="nt"></plugins></span> |
| <span class="nt"></build></span> |
| |
| <span class="nt"></project></span> |
| </pre></div> |
| |
| |
| <h5 id="resources">Resources<a class="headerlink" href="#resources" title="Permanent link">¶</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> |