This website and its associated repositories, are deprecated and no longer supported by the OSGi Alliance. Please visit https://enroute.osgi.org for the latest supported version of OSGi enRoute.
This enRoute v2 archive site is kept for those who do not intend to use the latest version of OSGi enRoute. If you are new to OSGi enRoute, then please start with the latest OSGi enRoute.
JARs are extremely flexible, they can contain any type of resource. So far, we’ve only focused on packages. However, we can also copy resources from the JARs on our -buildpath
(or file system) into our target JAR.
The pull-parser__pull-parser-2.1.10.jar
contains an (empty) file in the root of the JAR named PullParser2.1.10_VERSION
. You can see that resource from the Bnd Bundle Path
container. Maybe the parser assumes this resource in its root so we better make sure it is included. To include resources from the -buildpath
or file system we use the -includeresource
instruction.
-includeresource: \
@pull-parser__pull-parser-2.1.10.jar!/PullParser*_VERSION
The -includeresource
instruction can take any resources from the file system but it has a nifty feature to also use resources from the -buildpath
. If you prefix a resource with @
then it will assume a JAR file. It will first look on the file system but if it is not there, it will look for that file name (not path) in the -buildpath
. You could include the whole JAR but with the !/
pattern you can single out a resource. (This is standard for JAR URLs.) The resource will then be copied to the same path in the target bundle.
And as usual in bnd, you can use a wildcard character ‘*’ to not hardcode the version number.
You can verify that the resource made it in the JAR Editor.