Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse-plugin-dev: How to get current bundle version?

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();

like image 681
Paul Verest Avatar asked Oct 09 '13 02:10

Paul Verest


1 Answers

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!

like image 134
Peter Kriens Avatar answered Sep 29 '22 00:09

Peter Kriens