Java Reference
In-Depth Information
Most of this customization is tweaking the Maven-produced manifest to match the one
generated by the existing Ant build. You can avoid this by extracting the common bnd
instructions to a shared file and using the -include directive to pull it into both Ant
and Maven builds. Using a separate file for bnd instructions also avoids two formatting
issues that can plague Maven bundle developers:
XML tags can't start with - , so bnd directives listed in XML instead start with _ .
Maven attempts to process any text containing ${...} , so use $(...) for bnd
macros.
Other issues to watch out for when you start bundling Maven projects include the
following:
The complete project class path is passed to bnd; so Export-Package: * will
embed the entire class path, dependencies and all—which may or may not be
what you want.
Bnd uses a pull approach. It doesn't zip up target/classes; so, if any classes are
missing or you see any unexpected additional classes, check your bnd instructions.
If you want to know more about how the maven-bundle-plugin translates your project
details into bnd instructions, you can use mvn -X install to enable debug logging. But
watch out: this output includes debug from all plugins used in the build, so you probably
want to save it somewhere so you can search for bundle details at your leisure.
You now know how to take an existing Maven project and turn it into a bundle
using the maven-bundle-plugin. Just as you did with Ant, you can use bnd instructions
to tweak the manifest and select the bundle content. Is that all the maven-bundle-
plugin does?
A.2.3
Embedding dependencies
In addition to translating project details into bnd instructions, the maven-bundle-plugin
adds a few headers of its own that let you embed Maven dependencies without having
to write lengthy Include-Resource headers. It also keeps the Bundle-ClassPath header
in sync, so any embedded JAR s are automatically available on the bundle's class path.
You won't be surprised to learn that the main header is called Embed-Dependency .
It accepts a comma-separated list of patterns that are matched against the project's
Maven dependency tree. Matching dependencies can either be embedded or selec-
tively unpacked inside the bundle. The full syntax of the Embed-Dependency header is
as follows:
dependencies ::= clause ( ',' clause ) *
clause ::= MATCH ( ';' attr '=' MATCH | ';inline=' inline )
attr ::= 'groupId' | 'artifactId' | 'version' | 'scope' | 'type' |
'classifier' | 'optional'
inline ::= 'true' | 'false' | PATH ( '|' PATH ) *
MATCH ::= <globbed regular expression>
PATH ::= <Ant-style path expression>
Search WWH ::




Custom Search