Reputation: 387
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?
Upvotes: 0
Views: 151
Reputation: 4989
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.
Upvotes: 2