• Retrieving a feature's version number in Eclipse

Retrieving a feature's version number in Eclipse

I wanted to print in the log my feature’s version number, but was stumped because features aren’t OSGi bundles and there wasn’t an obvious way to find them. After realizing that the About dialog displays the features, I looked at its code and extracted this snippet:

IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
if (providers != null) {
  for (IBundleGroupProvider provider : providers) {
    IBundleGroup[] bundleGroups = provider.getBundleGroups();
    for (IBundleGroup group : bundleGroups) {
      if (group.getIdentifier().equals(featureId)) {
        version = group.getVersion();
      }
    }
  } 
}