0

There is a similar question on SE, but the answers only work for detecting the versions of available plug-ins.

I however look for a way to retrieve the version number of a user-defined feature at runtime.

Let's say I defined a feature com.me.prog.prod.feature that defines plugin dependencies and is later used in a product definition com.me.prog.prod.product. When launching com.me.prog.prod.product I want to be able to retrieve the version information of com.me.prog.prod.feature as I want to use it for top-level program versioning.

Is there a way to do this using Eclipse RCP framework code?

Community
  • 1
  • 1
Simon Voggeneder
  • 377
  • 1
  • 7
  • 16

1 Answers1

2

The following should get you the feature version number:

String version = null;
IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
for (IBundleGroupProvider provider : providers) {
    IBundleGroup[] groups = provider.getBundleGroups();
    for (IBundleGroup group : groups) {
        if ("com.me.prog.prod.feature".equals(group.getIdentifier())) {
            version = group.getVersion();
        }
    }
}

You will have to give the specific feature name in there as a plugin could potentially belong to more than one feature.

Nick Wilson
  • 4,959
  • 29
  • 42
  • Unfortunately, this does not solve the problem. While your code neatly lists a number of features provided by the platform (eclipse.rcp, emf, eclipse.help), any user-defined features are not present. – Simon Voggeneder Apr 24 '12 at 12:58
  • I have test projects set up with a custom product and feature. If I export the product from the product editor the above code shows the custom feature (although it doesn't when run through the Eclipse launcher). There also seem to be a number of other configuration settings that could cause the feature not to be listed, such as not entering the branding plugin in the feature.xml. – Nick Wilson Apr 24 '12 at 15:44