Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

How to Wrap Bundles

fhuberts edited this page Apr 3, 2013 · 5 revisions

Many of us need to wrap bundles so that we can use them. The following is a short recipe how to use bndtools to maintain these wrapped bundles.

  • Just create a new project in bndtools for all (or related) jars that you want to convert.
    
  • Give this project a name that will be the prefix of the bundle symbolic name of the converted jars. E.g. if your company is acme, call the project 'com.acme'
    
  • Download the jar and sources in a jar directory
  • Create a new bundle descriptor with a -classpath entry (File/New/Bundle Descriptor), for example:
-classpath: jar/htmlcleaner-2.2.jar, jar/htmlcleaner-2.2-src.zip
Export-Package: org.htmlcleaner.*;version=1.0
Import-Package: org.apache.tools.ant;resolution:=optional,\
  org.jdom;resolution:=optional,\
  *
Bundle-Version: 2.2.1

After saving this file, look in the generated directory, voila, there is your bundle! You can reuse the same project for any number of bundles you want to wrap.

You can then release the bundle to one of the repositories. Select the bnd.bnd file and select Release Bundle with the context menu.

Known Issues

You can't directly use a 'wrap' project from other projects, since Eclipse needs the source tree for that to work. There are 2 workarounds for this:

  • Put the wrapped bundled in a repository and use it from there (as described above)
  • Unpack the source tree in the src folder of the project

We're thinking on how we can fix this but haven't found a solution so far. See https://github.com/bndtools/bndtools/issues/579