Feature Dependencies匹配规则:未指定版本报错、默认规则疑问
Eclipse Feature 依赖配置相关问题解答
无版本依赖显示错误图标但无提示的原因
配置Feature必需依赖项时,若添加test.feature.A依赖且不指定版本,Feature节点显示错误图标但查询不到对应错误提示,对应现象截图:
相关配置文件
test.feature.A 配置
<?xml version="1.0" encoding="UTF-8"?> <feature id="test.feature.A" label="A" version="1.0.0.qualifier"> <description url="http://www.example.com/description"> [Enter Feature Description here.] </description> <copyright url="http://www.example.com/copyright"> [Enter Copyright Description here.] </copyright> <license url="http://www.example.com/license"> [Enter License Description here.] </license> </feature>
test.feature.B 配置
<?xml version="1.0" encoding="UTF-8"?> <feature id="test.feature.B" label="B" version="2.0.0.qualifier"> <description url="http://www.example.com/description"> [Enter Feature Description here.] </description> <copyright url="http://www.example.com/copyright"> [Enter Copyright Description here.] </copyright> <license url="http://www.example.com/license"> [Enter License Description here.] </license> <requires> <import feature="test.feature.A"/> </requires> </feature>
问题原因
这个现象是Eclipse PDE(插件开发环境)的已知校验逻辑缺陷:
- 不指定版本的Feature依赖本身不属于XML语法错误,但PDE校验器处理无版本依赖时,会默认匹配已发布的确定版本Feature,无法识别工作区中带
qualifier后缀的快照版Feature作为合法匹配项 - 该校验分支没有配套的错误提示文本生成逻辑,因此只会在节点上标记错误图标,不会输出可查询的具体错误信息
- 解决方式:要么为依赖显式指定版本号,要么将目标Feature导出为正式发布版(去掉qualifier后缀)后再做依赖校验。
指定版本但未配置Match Rule的默认生效规则
对应配置示例如下:
<requires> <import feature="test.feature.A" version="1.0.0.qualifier"/> </requires>
未显式配置match属性时,默认生效兼容(compatible)匹配规则,具体逻辑:
- 等价于显式配置
match="compatible" - 版本匹配区间为
[指定版本主版本号.0.0, 指定版本主版本号+1.0.0),以上述配置为例,匹配所有1.0.0 ≤ 版本 < 2.0.0的test.feature.A - 版本比对时会自动忽略
qualifier后缀,配置version="1.0.0.qualifier"和version="1.0.0"的匹配范围完全一致。
内容的提问来源于stack exchange,提问作者Jarvis Yu
相关产品推荐
相关产品推荐

