我们如何创建特定于操作系统的插件 [英] How do we create OS specific plugins

查看:65
本文介绍了我们如何创建特定于操作系统的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设计一个特定于操作系统的插件。根据操作系统(MAC或Windows),插件的内容将有所不同。

I have a requirement to design a plugin which is OS specific. Depending on OS (MAC or Windows), the content of the plugin will vary.

当前,我们正在维护两个不同的插件,一个用于Windows,另一个用于MAC,插件ID为com.core.win和com.core.mac。

Currently we are maintaining two different plugins, one for Windows and other for MAC, plugin id's com.core.win and com.core.mac.

我的主插件依赖于上述插件。但是由于我的插件ID因操作系统而异,因此两个插件都在插件依赖关系中添加为可选。

My main plugin is dependent on above plugin. But as my plugin ID is different depending on OS, both the plugins are added in Plug-ins Dependency as "Optional".

com.core.win; resolution:=optional,
com.core.mac; resolution:=optional

但实际上,依赖性是必须的,必需。如何设计我的插件结构,以便可以定义紧密的依赖关系?有没有标准的解决方法?

But in reality the dependency is a must, "Required". How do I design my plugin structure, such that a tight dependency can be defined ? Is there any standard solution approach ?

谢谢!

推荐答案

通常,您有一个基本插件,每个平台都有特定于平台的片段。

Usually you have one base plugin with a platform specific fragment for each platform.

您使用 Eclipse-PlatformFilter 清单.MF条目以指定平台,例如:

You use the Eclipse-PlatformFilter MANIFEST.MF entry to specify the platform, something like:

Eclipse-PlatformFilter: (& (osgi.ws=cocoa) (osgi.os=macosx) (osgi.arch=x86_64) )

,它指定可可窗口系统, Mac OS X操作系统和64位(这是当前Mac的正常设置)。

which specifies the Cocoa window system, Mac OS X operating system and 64 bit (this is the normal setting for current Macs).

在plugin.xml / MANIFEST.MF编辑器中,这是平台过滤器 概述标签的常规信息部分。

In the plugin.xml/MANIFEST.MF editor this is the 'Platform Filter' field in the 'General Information' section of the 'Overview' tab.

此处是有关片段的很好的介绍,Eclipse PDE帮助中也有文档。同样,SWT是针对特定于平台的代码使用片段的一个很好的示例。请参阅此常见问题解答,以了解如何获取SWT代码进行检查(并不需要实际执行构建和导出部分。)

Here is a good introduction about fragments, the Eclipse PDE Help also has documentation. Also, SWT is a good example of usage of fragments for platform-specific code. See this FAQ entry to learn how to get the SWT code for inspection (you don't need to actually do the build and export part).

这篇关于我们如何创建特定于操作系统的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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