Java Reference
In-Depth Information
unpleasant! Next, because you know that neither of your imports is optional, you should
make your imports compulsory by adding an Import-Package header. This doesn't
require you to list the imports, because you can use * as a wildcard. As with build-time
usage of bnd, any spurious imports can be individually removed using a !<package
name> entry. Finally, you should tighten the package exports by overriding the default
Export-Package: * used by bnd. In this case, you don't want to export anything, so leave
the entry blank. It's also a good idea to let bnd know which packages in your bundle have
private implementation using the Private-Package entry.
In the general case, you may find that you want to keep some package imports
optional because they're associated with poorly modularized optional code paths.
These can be explicitly added to the Import-Package section of the bnd file including
the resolution:=optional directive.
When you've finished writing your bnd file, you should have something that looks
like this:
Bundle-Name: Fancy Foods Chocolate Bundle
Bundle-SymbolicName: fancyfoods.department.chocolate
Bundle-Version: 1.0.0
Private-Package: fancyfoods.chocolate
Import-Package: *
To use the bnd file, you need to add a -properties <bndFile.bnd> argument when
you invoke bnd, as follows:
java -jar /biz.aQute.bnd.jar wrap -properties
The manifest for the resulting bundle, shown in the following listing, should now look
much more like the original, well-modularized manifest for the Fancy Foods choco-
late department; the only missing bits of information are version ranges on the pack-
age imports.
Listing 12.2
A bnd manifest generated with configuration
Manifest-Version: 1
Bnd-LastModified: 1309602664432
Bundle-Blueprint: OSGI-INF/blueprint/*.xml
Bundle-ManifestVersion: 2
Bundle-Name: Fancy Foods Chocolate Bundle
Bundle-SymbolicName: fancyfoods.department.chocolate
Bundle-Version: 1.0.0
Created-By: 1.6.0 (IBM Corporation)
Private-Package: fancyfoods.chocolate
Tool: Bnd-1.44.0
Given that the manifest still isn't entirely right, there's a small amount of tinkering still
to do. Bnd does attempt to fill in the import version range for any package imports
that it generates, but in the absence of any information about the exported version of
Search WWH ::

Custom Search