Eclipse RCP从3.7迁移至4.16时Maven构建缺失依赖报错求助
问题描述
将Eclipse RCP从3.7(Indigo)版本迁移至4.16(2020-06)版本,使用Maven构建时出现报错,提示缺失依赖osgi.bundle; org.eclipse.update.configurator 3.4.600.v20200422-1910。已尝试在pom.xml中添加如下依赖,但构建仍失败:
<dependency> <groupId>org.eclipse.platform</groupId> <artifactId>org.eclipse.update.configurator</artifactId> <version>3.4.600</version> </dependency>
关键错误日志片段:
Installation failed.
Cannot complete the install because one or more required items could not be found.
Software being installed: CUBRID Migration 9.3.0.202401030657 (com.cubrid.cubridmigration.product 9.3.0.202401030657)
Missing requirement: toolingwin32.win32.x86_64org.eclipse.update.configurator 9.3.0.202401030657 requires 'osgi.bundle; org.eclipse.update.configurator 3.4.600.v20200422-1910' but it could not be found
...
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-p2-director-plugin:1.7.0:materialize-products (materialize-products) on project com.cubrid.cubridmigration.product: Installation of product com.cubrid.cubridmigration.product for environment win32/win32/x86_64 failed
错误分析
- 依赖版本不匹配:添加的依赖版本是
3.4.600,但实际需要的是带时间戳qualifier的完整版本3.4.600.v20200422-1910,Tycho构建对版本精确性要求较高。 - Target Platform未包含该构件:Tycho构建依赖Target Platform中定义的仓库和构件,仅在pom.xml中添加依赖可能无法让p2 director找到对应bundle。
- 产品配置存在自定义IU:日志中出现的
toolingwin32.win32.x86_64org.eclipse.update.configurator是自定义安装单元,可能是旧版本迁移时遗留的配置,它依赖标准bundle但未正确关联。
解决方案
1. 修正pom.xml中的依赖版本
使用完整的带qualifier的版本号,确保与报错中要求的版本完全一致:
<dependency> <groupId>org.eclipse.platform</groupId> <artifactId>org.eclipse.update.configurator</artifactId> <version>3.4.600.v20200422-1910</version> </dependency>
2. 更新Target Platform配置
在项目的.target文件中,确保添加了Eclipse 4.16(2020-06)的官方仓库,并勾选org.eclipse.update.configurator bundle:
- 仓库地址示例:
http://download.eclipse.org/releases/2020-06/ - 刷新Target Platform,确保该bundle被正确加载。
3. 清理产品配置中的自定义IU
打开项目的.product文件,切换到Dependencies标签页,查找并移除toolingwin32.win32.x86_64org.eclipse.update.configurator这个自定义安装单元,直接添加标准的org.eclipse.update.configurator bundle作为依赖。
4. 清理缓存并重新构建
执行以下命令清理Maven缓存和构建目录,强制更新依赖:
mvn clean install -U
内容的提问来源于stack exchange,提问作者Dongmin kim

