Search code examples
eclipsepluginsrcp

Get list of installed software in eclipse through program


Using Platform.getBundleGroupProviders() and org.eclipse.core.runtime.IBundleGroup I am able to retrieve the list of installed features in Eclipse, but, is there an API through which I can get the list of installed software?

Thanks for your help!


Solution

  • This code lists all the installable units in the current profile:

    ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
    
    String profileId = provisioningUI.getProfileId();
    
    ProvisioningSession provisioningSession = provisioningUI.getSession();
    
    IProfileRegistry profileReg = (IProfileRegistry)provisioningSession.getProvisioningAgent().getService(IProfileRegistry.SERVICE_NAME);
    
    IQueryable<IInstallableUnit> queryable = profileReg.getProfile(profileId);
    
    IQuery<IInstallableUnit> query = QueryUtil.createIUAnyQuery();
    
    IQueryResult<IInstallableUnit> result = queryable.query(query, new NullProgressMonitor());
    
    for (final IInstallableUnit iu : result)
      {
        System.out.println(iu);
      }
    

    I have left out lots of null checks and exception catching.

    You can use QueryUtil to create various other queries such as IUs which are groups.