如何在eclipse RCP中找到孤立插件? [英] How to find orphan plugins in eclipse RCPs?

查看:143
本文介绍了如何在eclipse RCP中找到孤立插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用RCP更新网站会禁止孤立插件,否则不在功能中的插件。
如果未填写此条件,更新管理器将返回以下错误:
结果配置不包含该平台。

Update sites with RCPs prohibits orphan plugins, otherwise plugins that are not in a feature. If this condition is not filled, the update manager returns the following error: Resulting configuration does not contain the platform.

不幸的是,没有办法以确定哪些插件是孤儿。
如何找到孤立插件?

Unfortunately, no way to determine which plugins are orphan. How to find orphan plugins ?

推荐答案

这是一个起点(这适用于Eclipse 3.4及更高版本, P2存储库被引入,早期版本存储其配置不同,IIRC可以看到platform.xml中的所有插件和功能)。

Here's a starting point (this applies for Eclipse 3.4 and later, when the P2 repository was introduced, earlier versions store their configuration differently. IIRC you could see all the plugins and features in platform.xml).

创建一个新的插件项目(New- >其他 - >插件开发 - >插件项目)与Hello World模板,然后将此代码放入SampleAction的运行方法。

Create a new plugin project (New->Other->Plug-in Development->Plug-in Project) with the "Hello World" template then drop this code into the run method of the SampleAction.

运行该插件作为测试Eclipse应用程序,并选择Sample Menu-> Sample Action,不属于功能的插件将被输出到父工作区的控制台。当我运行这个比我预期的还要多一点,我已经看了几遍,不能发现逻辑错误。

Run the plugin as a test Eclipse Application and select Sample Menu->Sample Action, the plugins that don't belong to a feature will be output to the parent workspace's console. When I ran this there were quite a few more than I expected, I've had a few looks through and can't spot the logic error.

编辑,找到逻辑错误,正在使用最内层循环中使用的错误的数组索引。仍然不太正确。

Edit, found logic error, was using the wrong array index used in innermost loop. Still not quite right though.

编辑2.(Facepalm时刻)发现问题。确保使用所有工作区和启用的目标插件运行目标工作区,否则会显示斜线。如果你安装插件并打扮一下就不会有这个问题。

Edit 2. (Facepalm moment) Found the problem. Be sure to run the target workspace with all workspace and enabled target plugins enabled, or it will skew your results, obviously. If you install the plugin and dress it up a little bit you won't have this problem.

//get all the plugins that belong to features
IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();

Map<Long, IBundleGroup> bundlesMap = new HashMap<Long, IBundleGroup>();

if (providers != null) {
    for (int i = 0; i < providers.length; i++) {
        IBundleGroup[] bundleGroups = providers[i].getBundleGroups();

        System.out.println("Bundle groups:");
        for (int j = 0; j < bundleGroups.length; j++) {
            Bundle[] bundles = bundleGroups[j] == null ? new Bundle[0] : bundleGroups[j]
                    .getBundles();
            System.out.println(bundleGroups[j].getIdentifier());
            for (int k = 0; k < bundles.length; k++) {
                bundlesMap.put(bundles[k].getBundleId(), bundleGroups[j]);
            }                
        }
    }
}

BundleContext bundleContext = Activator.getDefault().getBundle().getBundleContext();

if(bundleContext instanceof BundleContextImpl) {            
    Bundle[] bundles = ((BundleContextImpl)bundleContext).getBundles();

    System.out.println("Orphan Bundles:");
    for (int i = 0; i < bundles.length; i++) {
        if(!bundlesMap.containsKey(bundles[i].getBundleId())) {
            System.out.println(bundles[i].getSymbolicName());
        }
    }            
}

这篇关于如何在eclipse RCP中找到孤立插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆