【问题标题】:P2 Garbage Collector not deleting pluginsP2 垃圾收集器不删除插件
【发布时间】:2019-08-05 21:19:10
【问题描述】:

我有一个 RAP 应用程序,我使用 P2 Operations API (org.eclipse.equinox.p2.operations) 根据某些命令行参数安装删除功能。

功能已正确安装和删除,但已删除功能的插件不会被删除。

经过一番搜索,我看到了我的问题的答案:Equinox/p2/FAQ

我尝试安装如下功能:

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

关闭系统,然后重新启动并卸载该功能,确保显式调用 p2 垃圾收集器。见以下代码:

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);
}

很遗憾,功能卸载后插件还在。

如何确保我正确指定了“org.eclipse.update.install.features=true”属性,似乎 -profileProperties org.eclipse.update.install.features=true 没有执行把戏。

另外,有没有办法将此属性默认设置为true?

难道我还缺少别的东西?

[编辑 1] 经过一些故障排除后,我发现使用 tycho 实现的产品可以配置为将配置文件属性 org.eclipse.update.install.features 设置为 true。其实按照tycho的配置就是默认的了。

【问题讨论】:

  • 要删除下次启动时不再需要的插件,在plugin_customization.ini中添加org.eclipse.equinox.p2.ui.sdk.scheduler/gcOnStartup=true行。
  • @howgler 感谢您的评论,但这不是我问题的答案,我在问题中包含的链接中已经提到了该选项

标签: eclipse p2


【解决方案1】:

我在 Eclipse 论坛中收到了对该问题的解释。

问题在于每次执行操作时,p2 都会创建一个新版本的配置文件。因此,当卸载后立即调用 GC 时,它将使用配置文件的当前版本,而不是使用卸载操作更新的配置文件。

现在,在启动时显式调用 GC 时,它会清除留下的插件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-26
    • 2011-07-24
    • 2012-03-24
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 2011-11-07
    • 2013-04-01
    相关资源
    最近更新 更多