Manually specify package version in exports when running 'bnd wrap'.

111 views
Skip to first unread message

kgilmer

unread,
Aug 18, 2011, 9:08:05 PM8/18/11
to bndtools-users

Hello,

I have an external dependency (Apache Commons I/O) that I am
wrapping with BND. BND does not add any versioning to the package
exports manifest header. I understand why this is not automatically
done as read in other threads, however I would like to manually
specify the package versions myself ("2.0.1"). Since this is an
external jar, I cannot add/update the package info or other internal
information of the jar. How can I do this with bnd?

thanks!
ken

kgilmer

unread,
Aug 18, 2011, 9:18:35 PM8/18/11
to bndtools-users

I found out how to do this with bnd. I create a file with the
contents:

Export-Package: *;version=2.0.1

Then I pass that file via the -properties operator into bnd. It then
generates the manifest with the version I want. A minor gripe; I'd
like to be able to specify this without creating a file, it makes
automation (slightly) harder.

thx!
ken

Neil Bartlett

unread,
Aug 18, 2011, 10:51:44 PM8/18/11
to bndtool...@googlegroups.com
Hi Ken,

Why would you automate wrapping of external dependencies? Isn't it
just a one-off task (per-library, at least) that only needs to be
revisited occasionally to tweak the exports etc?

For this reason I prefer to have the wrapping metadata saved in a
file, so I can revise what I did last time rather than start over.

Cheers,
Neil

Christopher Brind

unread,
Aug 19, 2011, 2:57:56 AM8/19/11
to bndtool...@googlegroups.com
Hi Ken,

Last time I checked (about 2 minutes ago) Apache Commons IO is already packaged as an OSGi bundle.  I've included the MANIFEST.MF's data below.


Cheers,
Chris


Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: 1.5.0_22 (Sun Microsystems Inc.)
Built-By: pemben
Build-Jdk: 1.5.0_22
Implementation-Title: Commons IO
Implementation-Vendor: The Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Version: 2.0.1
Specification-Title: Commons IO
Specification-Vendor: The Apache Software Foundation
Specification-Version: 2.0.1
X-Compile-Source-JDK: 1.5
X-Compile-Target-JDK: 1.5
Bnd-LastModified: 1293076177722
Export-Package: org.apache.commons.io.output;version="2.0.1",org.apach
 e.commons.io.comparator;version="2.0.1",org.apache.commons.io;version
 ="2.0.1",org.apache.commons.io.monitor;version="2.0.1",org.apache.com
 mons.io.input;version="2.0.1",org.apache.commons.io.filefilter;versio
 n="2.0.1"
Bundle-Version: 2.0.1
Bundle-Description: Commons-IO contains utility classes, stream implem
 entations, file filters, file comparators and endian classes.
Bundle-Name: Commons IO
Bundle-ManifestVersion: 2
Bundle-Vendor: The Apache Software Foundation
Bundle-SymbolicName: org.apache.commons.io
Tool: Bnd-0.0.255

kgilmer

unread,
Aug 19, 2011, 6:18:21 AM8/19/11
to bndtools-users
Hi Neil,

Well, the wrapping is done as part of an OpenEmbedded build recipe
[1], which among a bunch of other recipes is used to build our Linux
distro from scratch. OpenEmbedded's Java support is pretty basic.
Regarding storing the version in a file, yes I ended up creating a
package export variable inside the commons-io recipe such that any
time the package is built (via Ant), the package metadata is updated.
The good news is that with the property file, I'm able to produce a
nice bundle with package versioning.

cheers
ken

1: https://github.com/buglabs/oe-buglabs/blob/buglabs-sw2.1/recipes/jakarta-commons/commons-io_2.0.1.bb

kgilmer

unread,
Aug 19, 2011, 6:22:39 AM8/19/11
to bndtools-users

Hi Chris,

Yes, sadly I'm in kind of a weird position of wanting to build from
sources rather than just consume the binary jar, but need to use Ant
as the top-level build system I am using does not support Maven
(OpenEmbedded). As is, the Ant scripts do not generate the OSGi
headers. I could patch the build file (or add package metadata in the
sources) but I decided having bnd do the work for me would pay off as
the number of OGSi-ified jars increased. Additionally all my changes
to the target package would be isolated to my build file.

thanks!
ken
Reply all
Reply to author
Forward
0 new messages