Hello,

Is there any correct way to get the version of a package with OSGi ?  I
didn't see anything on the Bundle or BundleContext other than the bundle
version.

When I create JAR files (without BND), I can add sections to the
MANIFEST.MF such as :

Name: org/osgi/service/log/
Implementation-Title: OSGi Log Service
Implementation-Vendor: MyVendorName
Specification-Title: OSGi Log Service
Specification-Vendor: OSGi Alliance
Specification-Version: 1.3.0

...which is available from
MyLogServiceImpl.class.getPackage().getSpecificationVersion() (which I can
then parse into an OSGi Version object).  Indeed, even the standard JDK
classes work this way.

For example, when I introspect the OSGi compendium (for example, here:
http://repo1.maven.org/maven2/org/osgi/org.osgi.compendium/4.2.0/ ), I'm
resorting to a fallback approach, seeking out the "packageinfo" file (a
text stub, containing "version 1.3" for example).

My use case isn't "production", it's for an application that can create new
"plugin" OSGi projects into an existing frameworks by selecting required
services and services to publish by introspecting a fixed set of bundles
(so that customers can extend the base functionality of our application).

Thanks,
Christopher

Reply via email to