Eclipse P2问题:自定义Provisioning Action插件更新异常及依赖冲突
Eclipse插件p2更新冲突与自定义动作版本不匹配问题解决
问题背景
开发Eclipse插件时遇到两个关联问题:
- pluginA的
META-INF/p2.inf包含安装/更新配置指令,pluginB包含自定义ProvisioningAction类 - 更新pluginA的p2.inf和pluginB的自定义动作后,p2执行了新版p2.inf,但运行的是pluginB旧版动作代码
- 修改p2.inf的
metaRequirement版本为1.14.7后,出现插件新旧版本冲突,无法完成安装
错误信息
Cannot complete the install because of a conflicting dependency. Software being installed: FSD Core Application (Required) 1.14.7.202509161557 (com.mycorp.pluginApp.feature.group 1.14.7.202509161557) Only one of the following can be installed at once: FSD P2 Touchpoint 1.14.1.v20250327-518478546144 (com.mycorp.pluginB 1.14.1.v20250327-518478546144) FSD P2 Touchpoint 1.14.7.202509161557 (com.mycorp.pluginB 1.14.7.202509161557) Cannot satisfy dependency: From: FSD Core Application (Required) 1.14.7.202509161557 (com.mycorp.pluginApp.feature.group 1.14.7.202509161557) To: org.eclipse.equinox.p2.iu; com.mycorp.pluginB [1.14.7.202509161557,1.14.7.202509161557] Cannot satisfy dependency: From: FSD Core Application (Required) 1.14.7.202509161557 (com.mycorp.pluginApp.feature.group 1.14.7.202509161557) To: org.eclipse.equinox.p2.iu; com.mycorp.pluginA [1.14.7.202509161557,1.14.7.202509161557] Cannot satisfy dependency: From: FSD Product 1.14.7.202509161557 (com.mycorp.pluginA 1.14.7.202509161557) To: org.eclipse.equinox.p2.iu; com.mycorp.pluginB [1.14.7,2.0.0)
现有配置
pluginA的p2.inf配置
metaRequirements.0.namespace=org.eclipse.equinox.p2.iu metaRequirements.0.name=com.mycorp.pluginB metaRequirements.0.range=1.14.7 # Tell p2 that the new IU replaces older ones in this range update.replace.0.id=com.mycorp.pluginB update.replace.0.range=[1.0.0,1.14.7) ... <some p2 touchpoint instructions below> ...
pluginB的plugin.xml配置
<plugin> <extension point="org.eclipse.equinox.p2.engine.actions"> <action class="com.mycorp.pluginB.actions.UpgradeCopyAction" name="upgradeCopy" touchpointType="com.mycorp.pluginB.touchpoints.type" version="1.14.7"> </action> </extension> <extension id="fsd" name="FSD Touchpoint" point="org.eclipse.equinox.p2.engine.touchpoints"> <touchpoint class="com.mycorp.pluginB.touchpoints.FsdP2Touchpoint" type="com.mycorp.pluginB.touchpoints.type" version="1.14.7"> </touchpoint> </extension> </plugin>
问题分析与解决方案
核心问题
- 自定义动作未被正确更新:p2执行touchpoint动作时加载了旧版pluginB类,原因是pluginB的版本替换规则未生效,或touchpoint动作版本绑定不明确
- 依赖冲突:feature直接依赖pluginB的精确版本,与pluginA的范围依赖矛盾,且旧版pluginB未被自动替换
具体修复步骤
1. 给pluginB添加版本替换声明
在pluginB的META-INF/MANIFEST.MF中添加p2替换属性,明确新版可替换旧版:
Bundle-Version: 1.14.7.202509161557 Bundle-SymbolicName: com.mycorp.pluginB;singleton:=true # 声明新版可替换旧版范围 p2.replace: com.mycorp.pluginB;range="[1.0.0,1.14.7.202509161557)"
2. 调整p2.inf的依赖范围与替换规则
修改pluginA的p2.inf,让依赖范围匹配pluginB的精确构建版本,同时更新替换范围:
metaRequirements.0.namespace=org.eclipse.equinox.p2.iu metaRequirements.0.name=com.mycorp.pluginB # 使用精确版本匹配pluginB的构建号 metaRequirements.0.range=[1.14.7.202509161557,1.14.7.202509161557] # 替换范围覆盖到当前版本之前的所有旧版 update.replace.0.id=com.mycorp.pluginB update.replace.0.range=[1.0.0,1.14.7.202509161557)
3. 统一feature与pluginA的依赖范围
修改com.mycorp.pluginApp.feature的feature.xml,将pluginB的依赖范围调整为与pluginA一致的[1.14.7,2.0.0),避免精确版本冲突:
<plugin id="com.mycorp.pluginB" range="[1.14.7,2.0.0)" download-size="0" install-size="0" unpack="false"/>
4. 绑定touchpoint动作到pluginB的精确版本
更新pluginB的plugin.xml,让动作和touchpoint的版本与Bundle版本完全一致,添加id确保p2识别新版本:
<extension point="org.eclipse.equinox.p2.engine.actions"> <action id="com.mycorp.pluginB.upgradeCopy" class="com.mycorp.pluginB.actions.UpgradeCopyAction" name="upgradeCopy" touchpointType="com.mycorp.pluginB.touchpoints.type" version="1.14.7.202509161557"> </action> </extension> <extension id="fsd" name="FSD Touchpoint" point="org.eclipse.equinox.p2.engine.touchpoints"> <touchpoint id="com.mycorp.pluginB.touchpoint" class="com.mycorp.pluginB.touchpoints.FsdP2Touchpoint" type="com.mycorp.pluginB.touchpoints.type" version="1.14.7.202509161557"> </touchpoint> </extension>
5. 清理并重新构建更新站点
- 清理所有项目的
bin、target等构建目录 - 重新执行插件构建,生成新的更新站点
- 确保更新站点中仅保留pluginB的1.14.7版本,移除旧版文件
验证逻辑
- pluginB的
p2.replace属性会触发p2自动卸载旧版、安装新版 - feature与pluginA的依赖范围统一,消除版本冲突
- touchpoint动作与Bundle版本绑定,确保p2加载新版pluginB中的动作类
内容的提问来源于stack exchange,提问作者Che
相关产品推荐
相关产品推荐

