【发布时间】: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 感谢您的评论,但这不是我问题的答案,我在问题中包含的链接中已经提到了该选项