[resolved] Using Equinox P2 - Getting information about installed features and plugins [message #716107] |
Tue, 16 August 2011 13:20 |
Jose Renato Messages: 12 Registered: February 2011 |
Junior Member |
|
|
I'm using Eclipse 3.7 to develop a project and I need to do some things, using the information of installed plugins and features:
I'm using the P2 provisioning feature to allow software updates.
1: I need to get the list of plugins and features that are installed and currently running. I need something like what is displayed on the "Installed Software", which can be viewed through "Help> About> Installation Details".
Note: I will use this information to obtain data about features installed, such as version number and description.
2: I need to get a list of recent installed softwares. I need something like what is displayed on the "Installation History", which can be viewed through "Help> About> Installation Details".
Note: I will use this information to add functionality to clear older installations. Something like "Keep only the last five installations."
[Updated on: Thu, 18 August 2011 12:16] Report message to a moderator
|
|
|
|
Re: Using Equinox P2 - Getting information about installed features and plugins [message #716454 is a reply to message #716152] |
Wed, 17 August 2011 13:02 |
Jose Renato Messages: 12 Registered: February 2011 |
Junior Member |
|
|
Hi Martin,
thanks for the answer.
I tried to do that, but it did not returned what I needed.
I have the following features and plugins structure:
feature.1
- feature.1.1
-- plugin.1.1.1
-- plugin.1.1.2
- feature.1.2
-- plugin.1.2.1
So, what I wanted to do is to get the version of the feature.1, but, with the code above, only the features feature.1.1 and feature.1.2 were returned.
Then, with this code, I got what I needed:
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
...
try {
ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
if ( null == provisioningUI ) {
return;
}
String profileId = provisioningUI.getProfileId();
ProvisioningSession provisioningSession = provisioningUI.getSession();
if ( null == provisioningSession ) {
return;
}
IQueryable<IInstallableUnit> queryable = ((IProfileRegistry) provisioningSession.getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME))
.getProfile( profileId );
if ( null == queryable ) {
return;
}
// to get the product ID
//String pId = Platform.getProduct().getId();
String pId = "feature.1";
if ( null != queryable ) {
IQueryResult<IInstallableUnit> iqr = queryable.query( QueryUtil.createIUQuery( pId ), null );
if ( null != iqr ) {
Iterator<IInstallableUnit> ius = iqr.iterator();
if( ius.hasNext() ) {
IInstallableUnit iu = ius.next();
Version v = iu.getVersion();
if ( null != v ) {
System.out.println( "ID: " + iu.getId() + " | IU: " + iu.toString() + " | Version: " + v.toString() );
}
}
}
}
} catch ( Exception e ) {
System.out.println( e.getStackTrace() );
return;
}
|
|
|
Powered by
FUDForum. Page generated in 0.01963 seconds