尽管 Eclipse 插件导出中存在循环依赖错误,但我在依赖项中找不到循环:如何调试?
当我尝试使用 Eclipse 导出插件时,收到错误消息“生成类路径时检测到循环”。
接下来是一个插件列表,它显然显示了循环,形式如下:
a.b.c.plugin-u_version,
**a.b.c.plugin-w_version**,
a.b.c.plugin-x_version,
a.b.c.plugin-y_version,
a.b.c.plugin-z_version,
**a.b.c.plugin-w_version**.
请注意,根据此列表,看来plugin-w依赖于plugin-z,但plugin-z依赖于plugin-w。
当我检查这些插件的依赖关系时,通过打开 MANIFEST.MF 并检查“依赖关系”选项卡,并通过查看清单中的“Required-bundle:”属性,我确认了所有这些依赖关系,直到最后一个。
也就是说,在 abcplugin-z 的 MANIFEST.MF 中,我没有看到对 plugin-w 的任何依赖。
我读的错误正确吗?如果是这样,我该如何调试错误来自哪里?
when I try to export a plug-in using Eclipse, I get the error message "A cycle was detected when generating the classpath".
This is followed by a list of plug-ins which apparently shows the cycle, in this form:
a.b.c.plugin-u_version,
**a.b.c.plugin-w_version**,
a.b.c.plugin-x_version,
a.b.c.plugin-y_version,
a.b.c.plugin-z_version,
**a.b.c.plugin-w_version**.
Note that according to this list, it appears that plugin-w depends on plugin-z, but plugin-z depends on plugin-w.
When I check the dependencies of these plugins, both by opening the MANIFEST.MF and checking the Dependencies tab, and by looking at the Required-bundle: property in the manifest, I confirm all of these dependencies, up until the very last one.
That is, in the MANIFEST.MF for a.b.c.plugin-z, I do not see any dependency on plugin-w.
Am I reading the error right? If so, how can I debug where the error is coming from?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题很难概括,而且我还没有完成所需的繁琐的全面分析,所以我正在回答我自己的问题,并希望它可以帮助其他搜索相同错误的人。
导出插件时出现的错误是“生成类路径时检测到循环”,但通过检查每个插件的依赖关系我没有看到循环。
问题来自于涉及到一个片段。链中的一个插件,假设它是上面的plugin.x,是另一个未在依赖项链中列出的插件的片段主机,并且该第二个插件具有引入了循环。
我们将未在依赖链中列出的插件称为“plugin.x1”。
在plugin.x1 的 MANIFEST.MF 文件中,我看到属性“Fragment-Host: abcplugin-x”。该属性使plugin-x 依赖于plugin-x1。
但plugin.x1 的 MANIFEST.MF 文件中的另一个属性为:“Import-Package: abcplugin-w”。
所以依赖关系是:w 依赖于 x; x 是 x1 的片段宿主; x1 取决于 w。如此循环。
干净的解决方案是:重新设计我的代码,通过避免片段主机配置来避免循环依赖。
对我有用的快速而肮脏的解决方案是:每当我想导出我的plugin.u 时,关闭项目plugin.x1。
This question is difficult to generalize, and I have not done the tedious full analysis needed to, so I'm answering my own question and hoping it helps others who search for the same error.
The error I get, when exporting a plug-in, is "A cycle was detected when generating the classpath", but I don't see the cycle by examining the dependencies of each plug-in.
The problem comes from the fact that there is a fragment involved. One of the plug-ins in the chain, let's say it's plugin.x, above, is a fragment host for another plug-in that is not listed in the dependency chain, and that that second plug-in has a dependency that introduces the cycle.
Let's call the plug-in that is not listed in the dependency chain, "plugin.x1".
In the MANIFEST.MF file for plugin.x1, I see the attribute "Fragment-Host: a.b.c.plugin-x". This attribute makes plugin-x dependent on plugin-x1.
But another attribute in the MANIFEST.MF file for plugin.x1 reads: "Import-Package: a.b.c.plugin-w".
So the dependency is: w depends on x; x is a fragment host for x1; and x1 depends on w. Thus the cycle.
The clean solution is: redesign my code to avoid circular dependencies by avoiding the fragment host configuration.
The quick and dirty solution, which works for me is: close the project plugin.x1 whenever I want to export my plugin.u.
另一个快速但肮脏的解决方案是选中“导出”窗口底部的“允许目标平台中的二进制循环”复选框。
Another quick and dirty solution is to check the "Allow for binary cycles in target platform" checkbox at the bottom of the Export window.