eclipsep2

P2 Garbage Collector not deleting plugins


I have a RAP application and I using the P2 Operations API (org.eclipse.equinox.p2.operations) to install an remove features depending on certain command line arguments.

The features are installed and removed correctly, but the plugins of a removed feature are not deleted.

After some searching I saw what i though was the answer to my question: Equinox/p2/FAQ

I try to install a feature as follows:

myRapApp -install -profileProperties org.eclipse.update.install.features=true 

shutdown the system, then restart it and uninstall the feature making sure the the p2 garbage collector is explicitly invoke. See code below:

IQueryResult<IInstallableUnit> queryResult =  getInstalledIUfromID(rootIdToUninstall);

if (queryResult.isEmpty()) {
    log.error("Installable unit {} is not installed.", rootIdToUninstall);
    return false;
}

// --- If found, trigger an UninstallOperation ---------------
UninstallOperation uninstallOperation = new UninstallOperation(this.provisioningSession, queryResult.toSet());
IStatus result = this.performOperation(uninstallOperation);
if (!result.isOK()) {
    String childStatusStr = null;
    for ( IStatus children : result.getChildren()) {
        childStatusStr += "\t" + children.toString() + LINE_SEP;
    }
    log.error("Fail to uninstall {}: {} {} {}", rootIdToUninstall, result.getMessage(), LINE_SEP, childStatusStr);
    if ( result.getException() != null ) {
        log.error("Uninstalling exception:", result.getException());
    }
} else {
    IProfileRegistry profileRegistry = (IProfileRegistry) this.provisioningAgent.getService(IProfileRegistry.SERVICE_NAME);
    IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);

    GarbageCollector gc = (GarbageCollector)  this.provisioningAgent.getService(GarbageCollector.SERVICE_NAME);
    gc.runGC(profile);
}

Unfortunately, the plugins are still there after the feature is uninstalled.

How can I made sure that I am specifying the "org.eclipse.update.install.features=true" property correctly, it seems that the -profileProperties org.eclipse.update.install.features=true is not doing the trick.

Moreover, is there a way to set this property to true by default?

Could it be that I am still missing something else?

[Edit 1] After some trouble shooting I found out that products materialize using tycho can be configured to have the profile propertie org.eclipse.update.install.features set to true. In fact according to the tycho configuration that is the default.


Solution

  • I have receied an explanation of the issue in the Eclipse Forum.

    The problem is that each time you perform an operation, p2 creates a new version of the profile. Thus, when the GC was called right after the uninstall it would be working with the current version of the profile not the updated one with the uninstall operation.

    Now, when calling explicitly the GC at startup it clears the plugins left behind.