In a plug-in you can use:
Bundle bundle = Platform.getBundle("org.nodeeclipse.ui");
Version version = bundle.getVersion();
Version
has getMajor
, getMinor
, getMicro
, getQualifier
methods.
Platform
is org.eclipse.core.runtime.Platform
Question
In Eclipse plugin development: How to get current bundle version?
It is just in Manifest.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Nodeclipse
Bundle-SymbolicName: org.nodeclipse.ui;singleton:=true
Bundle-Version: 0.6.0.qualifier
Bundle-Activator: org.nodeclipse.ui.Activator
Require-Bundle: org.eclipse.ui,
However Java has method only to look at Bundle Implementation version
getClass().getPackage().getImplementationVersion();
Solution 2
In a plug-in you can use:
Bundle bundle = Platform.getBundle("org.nodeeclipse.ui");
Version version = bundle.getVersion();
Version
has getMajor
, getMinor
, getMicro
, getQualifier
methods.
Platform
is org.eclipse.core.runtime.Platform
OTHER TIPS
In a more OSGi way, not having to know your name, and official standard way:
Version version = FrameworkUtil.getBundle(getClass()).getVersion();
Notice that the bundle version you get is from the bundle from which the this was loaded. So do not put this in a convenience library in another bundle!