Java Reference
In-Depth Information
components, automatically generating valid
XML
at build time. You can even use bnd
annotations to mark up component classes and setter methods; list the component
class names in the header, and bnd will do the rest. The official bnd site has a com-
plete description of the
Service-Component
header as well as detailed examples.
A.1.3
Directives
If headers describe the
what
of bundles, then directives describe the
how
. They let you
fine-tune the packaging process so you get exactly the bundle you want. Some of the
more popular directives are as follows:
■
-classpath
—Comma-separated list of additional class path entries.
■
-donotcopy
—Regular expression of filenames that shouldn't be copied into the
bundle. The default excludes
CVS
and .svn directories.
■
-exportcontents
—Same syntax as
Export-Package
, but doesn't pull anything
into the bundle. Useful in multimodule projects when you want to provide some
general export instructions, but you don't want to affect the bundle contents.
■
-failok
—Still creates a bundle, even if errors are found in the instructions or
content.
■
-include
—Comma-separated list of properties files containing additional bnd
instructions. Properties from included files override existing properties unless
the name is prefixed with
~
. A missing filename causes a build error unless the
name is prefixed with -.
■
-manifest
—Uses the given manifest file for the bundle instead of generating one.
■
-nouses
—Disables generation of
uses
constraints. This can be useful if you
expect to deploy the bundle on Equinox or Eclipse, as the additional con-
straints can slow down the bundle-resolution process on certain frameworks.
■
-output
—Writes the generated bundle to the given file location.
■
-plugin
—List of plugin class names that augment or extend the bundling pro-
cess. Bnd includes optional plugins that can process Spring
XML
or generate
bundles on demand in the style of Make.
■
-removeheaders
—Comma-separated list of headers to remove from the final
manifest. Useful if you don't want bnd-specific headers like
Include-Resource
ending up in your final bundle.
■
-sources
—Automatically adds the source for any classes pulled into the bundle
under
OSGI-OPT
/src. The source code must either exist in a directory or
JAR
on
the class path, or be listed under the
-sourcepath
directive.
OSG
i-aware
IDE
s
like Eclipse automatically look for embedded sources and use them when
debugging, so adding them can help developers.
■
-versionpolicy
—Defines the policy to use when selecting import ranges. The
default policy is to only include the major and minor segments of the version,
with no upper limit. To give a concrete example: if you were building a
bundle against
SLF4J
1.5.8 with the default version policy, any generated
import for the
org.slf4j
package would use an open-ended range of
org.slf4j;version="1.5".