如何使 Eclipse 插件可部署在多个 Eclipse 版本中?
How to make a Eclipse plug-in deployable in many Eclipse versions?
我为 Eclipse Oxygen 3a 编写了自己的 Eclipse 插件。它在 Eclipse Oxygen 3a 中完美运行。
现在我需要在较新版本的 Eclipse 中部署相同的插件,但是当插件安装在 Eclipse Photon 中时,安装 window 说:
Cannot perform operation. Computing alternate solutions, may take a while: ...
确实拖了半天,结果说我的插件安装不上
如何使该插件适用于多个 Eclipse 版本?
更新 1
根据要求,这是 Require-Bundle:
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.core.resources,
org.eclipse.ui.editors,
org.eclipse.ui.views;bundle-version="3.8.0",
org.eclipse.ui.ide,
org.eclipse.jdt.ui;bundle-version="3.13.52",
org.eclipse.jdt.core;bundle-version="3.13.50"
没有导入包。
更新 2
下面可以看到feature.xml文件。我在内部 Apache Web 服务器中部署了一个插件站点,并使用 Eclipse 的“帮助”菜单中的 "Install new software" 选项从 thare 安装。
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="MyPluginFeature"
label="MyPlugin"
version="0.4.0"
provider-name="MyPlugin.com"
plugin="MyPlugin">
<description url="http://www.example.com/description">
</description>
<copyright url="http://www.example.com/copyright">
</copyright>
<license url="http://www.example.com/license">
</license>
<url>
<update label="MyPlugin site" url="http://acme.com/myplugin"/>
</url>
<requires>
<import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.core.filesystem" version="1.3.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.core.resources" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.13.0" match="compatible"/>
<import plugin="org.eclipse.core.filesystem" version="1.7.0" match="compatible"/>
<import plugin="org.eclipse.text" version="3.6.0" match="compatible"/>
<import plugin="org.eclipse.osgi" version="3.7.0" match="compatible"/>
<import plugin="org.eclipse.equinox.common" version="3.8.0" match="compatible"/>
<import plugin="org.eclipse.core.jobs" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.equinox.registry" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.equinox.preferences" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.core.contenttype" version="3.3.0" match="compatible"/>
<import plugin="org.eclipse.equinox.app" version="1.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.equinox.common" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.equinox.registry" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.osgi" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.core.commands" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.equinox.common" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.swt" version="3.103.0" match="compatible"/>
<import plugin="org.eclipse.jface" version="3.13.0" match="compatible"/>
<import plugin="org.eclipse.ui.workbench" version="3.105.0" match="compatible"/>
<import plugin="org.eclipse.core.expressions" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.swt" version="3.104.0" match="compatible"/>
<import plugin="org.eclipse.core.commands" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.equinox.common" version="3.3.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.compare.core" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.expressions" version="3.4.100" match="compatible"/>
<import plugin="org.eclipse.jface.text" version="3.8.0" match="compatible"/>
<import plugin="org.eclipse.ui" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.11.0" match="compatible"/>
<import plugin="org.eclipse.core.filesystem" version="1.2.0" match="compatible"/>
<import plugin="org.eclipse.core.filebuffers" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.resources" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.text" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.ltk.core.refactoring" version="3.7.0" match="compatible"/>
<import plugin="org.eclipse.jface.text" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.ui.navigator" version="3.3.200" match="compatible"/>
<import plugin="org.eclipse.compare" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.team.core" version="3.4.100" match="compatible"/>
<import plugin="org.eclipse.team.ui" version="3.4.100" match="compatible"/>
<import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.views" version="3.8.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.jdt.ui" version="3.13.52" match="greaterOrEqual"/>
<import plugin="org.eclipse.jdt.core" version="3.13.50" match="greaterOrEqual"/>
</requires>
<plugin
id="org.eclipse.core.resources"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.jdt.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.runtime"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.filesystem"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.text"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.equinox.common"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.jface"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui.workbench.texteditor"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ltk.core.refactoring"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ltk.ui.refactoring"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="MetaCoder"
download-size="0"
install-size="0"
version="0.4.0"
unpack="false"/>
</feature>
更新 3
修复window:
更新 4
在 Eclipse JEE 2019-Jul 中尝试安装插件失败后,我收到以下错误消息:
Cannot complete the install because of a conflicting dependency.
Software being installed: MyPlugin 0.4.0 (MyPluginFeature.feature.group 0.4.0)
Software currently installed: Eclipse Platform 4.13.0.v20190916-1323 (org.eclipse.platform.feature.group 4.13.0.v20190916-1323)
Only one of the following can be installed at once:
Core File Systems 1.7.500.v20190620-1312 (org.eclipse.core.filesystem 1.7.500.v20190620-1312)
Core File Systems 1.7.0.v20170406-1337 (org.eclipse.core.filesystem 1.7.0.v20170406-1337)
Core File Systems 1.7.400.v20190518-1151 (org.eclipse.core.filesystem 1.7.400.v20190518-1151)
Cannot satisfy dependency:
From: MyPlugin 0.4.0 (MetaCoderFeature.feature.group 0.4.0)
To: org.eclipse.equinox.p2.iu; org.eclipse.core.filesystem [1.7.0.v20170406-1337,1.7.0.v20170406-1337]
Cannot satisfy dependency:
From: Eclipse Platform 4.13.0.v20190916-1323 (org.eclipse.platform.feature.group 4.13.0.v20190916-1323)
To: org.eclipse.equinox.p2.iu; org.eclipse.core.filesystem [1.7.500.v20190620-1312,1.7.500.v20190620-1312]
更新 5
在功能编辑器中,我决定单击 [Compute] 按钮并重新计算所有依赖项。结果下面我们有了新的 feature.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="MyPluginFeature"
label="MyPlugin"
version="0.4.0"
provider-name="ACME"
plugin="MyPlugin">
<description url="http://www.example.com/description">
</description>
<copyright url="http://www.example.com/copyright">
</copyright>
<license url="http://www.example.com/license">
</license>
<url>
<update label="Site do MyPlugin" url="http://example.org/myplugin"/>
</url>
<requires>
<import plugin="org.eclipse.ui" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.jface.text" version="3.8.0" match="compatible"/>
<import plugin="org.eclipse.core.resources" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.views" version="3.8.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.jdt.ui" version="3.13.52" match="greaterOrEqual"/>
<import plugin="org.eclipse.jdt.core" version="3.13.50" match="greaterOrEqual"/>
</requires>
<plugin
id="MyPlugin"
download-size="0"
install-size="0"
version="0.4.0"
unpack="false"/>
</feature>
在feature.xml
中只能将自己的插件指定为<plugin ... />
,而不是需要的(Eclipse)plug-ins/bundles .
例如,
<plugin
id="org.eclipse.core.resources"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
使当前版本的plug-in/bundleorg.eclipse.core.resources
(version="0.0.0"
是一个占位符,在构建更新站点时将被当前版本替换)的一部分可以被安装。因为org.eclipse.core.resources
是一个单例plug-in/bundle(Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
),所以不能和其他版本的plug-in/bundle一起使用。这会阻止您的插件在许多 Eclipse 版本中部署。
我为 Eclipse Oxygen 3a 编写了自己的 Eclipse 插件。它在 Eclipse Oxygen 3a 中完美运行。
现在我需要在较新版本的 Eclipse 中部署相同的插件,但是当插件安装在 Eclipse Photon 中时,安装 window 说:
Cannot perform operation. Computing alternate solutions, may take a while: ...
确实拖了半天,结果说我的插件安装不上
如何使该插件适用于多个 Eclipse 版本?
更新 1
根据要求,这是 Require-Bundle:
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jface.text,
org.eclipse.core.resources,
org.eclipse.ui.editors,
org.eclipse.ui.views;bundle-version="3.8.0",
org.eclipse.ui.ide,
org.eclipse.jdt.ui;bundle-version="3.13.52",
org.eclipse.jdt.core;bundle-version="3.13.50"
没有导入包。
更新 2
下面可以看到feature.xml文件。我在内部 Apache Web 服务器中部署了一个插件站点,并使用 Eclipse 的“帮助”菜单中的 "Install new software" 选项从 thare 安装。
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="MyPluginFeature"
label="MyPlugin"
version="0.4.0"
provider-name="MyPlugin.com"
plugin="MyPlugin">
<description url="http://www.example.com/description">
</description>
<copyright url="http://www.example.com/copyright">
</copyright>
<license url="http://www.example.com/license">
</license>
<url>
<update label="MyPlugin site" url="http://acme.com/myplugin"/>
</url>
<requires>
<import plugin="org.eclipse.core.expressions" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.core.filesystem" version="1.3.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.core.resources" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.13.0" match="compatible"/>
<import plugin="org.eclipse.core.filesystem" version="1.7.0" match="compatible"/>
<import plugin="org.eclipse.text" version="3.6.0" match="compatible"/>
<import plugin="org.eclipse.osgi" version="3.7.0" match="compatible"/>
<import plugin="org.eclipse.equinox.common" version="3.8.0" match="compatible"/>
<import plugin="org.eclipse.core.jobs" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.equinox.registry" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.equinox.preferences" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.core.contenttype" version="3.3.0" match="compatible"/>
<import plugin="org.eclipse.equinox.app" version="1.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.equinox.common" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.equinox.registry" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.osgi" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.core.commands" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.equinox.common" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.2.0" match="compatible"/>
<import plugin="org.eclipse.swt" version="3.103.0" match="compatible"/>
<import plugin="org.eclipse.jface" version="3.13.0" match="compatible"/>
<import plugin="org.eclipse.ui.workbench" version="3.105.0" match="compatible"/>
<import plugin="org.eclipse.core.expressions" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.swt" version="3.104.0" match="compatible"/>
<import plugin="org.eclipse.core.commands" version="3.4.0" match="compatible"/>
<import plugin="org.eclipse.equinox.common" version="3.3.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.compare.core" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.expressions" version="3.4.100" match="compatible"/>
<import plugin="org.eclipse.jface.text" version="3.8.0" match="compatible"/>
<import plugin="org.eclipse.ui" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.11.0" match="compatible"/>
<import plugin="org.eclipse.core.filesystem" version="1.2.0" match="compatible"/>
<import plugin="org.eclipse.core.filebuffers" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.resources" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.text" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.ltk.core.refactoring" version="3.7.0" match="compatible"/>
<import plugin="org.eclipse.jface.text" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.ui.navigator" version="3.3.200" match="compatible"/>
<import plugin="org.eclipse.compare" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.team.core" version="3.4.100" match="compatible"/>
<import plugin="org.eclipse.team.ui" version="3.4.100" match="compatible"/>
<import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.views" version="3.8.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.jdt.ui" version="3.13.52" match="greaterOrEqual"/>
<import plugin="org.eclipse.jdt.core" version="3.13.50" match="greaterOrEqual"/>
</requires>
<plugin
id="org.eclipse.core.resources"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.jdt.core"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.runtime"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.core.filesystem"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.text"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.equinox.common"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.jface"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ui.workbench.texteditor"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ltk.core.refactoring"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="org.eclipse.ltk.ui.refactoring"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="MetaCoder"
download-size="0"
install-size="0"
version="0.4.0"
unpack="false"/>
</feature>
更新 3
修复window:
更新 4
在 Eclipse JEE 2019-Jul 中尝试安装插件失败后,我收到以下错误消息:
Cannot complete the install because of a conflicting dependency.
Software being installed: MyPlugin 0.4.0 (MyPluginFeature.feature.group 0.4.0)
Software currently installed: Eclipse Platform 4.13.0.v20190916-1323 (org.eclipse.platform.feature.group 4.13.0.v20190916-1323)
Only one of the following can be installed at once:
Core File Systems 1.7.500.v20190620-1312 (org.eclipse.core.filesystem 1.7.500.v20190620-1312)
Core File Systems 1.7.0.v20170406-1337 (org.eclipse.core.filesystem 1.7.0.v20170406-1337)
Core File Systems 1.7.400.v20190518-1151 (org.eclipse.core.filesystem 1.7.400.v20190518-1151)
Cannot satisfy dependency:
From: MyPlugin 0.4.0 (MetaCoderFeature.feature.group 0.4.0)
To: org.eclipse.equinox.p2.iu; org.eclipse.core.filesystem [1.7.0.v20170406-1337,1.7.0.v20170406-1337]
Cannot satisfy dependency:
From: Eclipse Platform 4.13.0.v20190916-1323 (org.eclipse.platform.feature.group 4.13.0.v20190916-1323)
To: org.eclipse.equinox.p2.iu; org.eclipse.core.filesystem [1.7.500.v20190620-1312,1.7.500.v20190620-1312]
更新 5
在功能编辑器中,我决定单击 [Compute] 按钮并重新计算所有依赖项。结果下面我们有了新的 feature.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<feature
id="MyPluginFeature"
label="MyPlugin"
version="0.4.0"
provider-name="ACME"
plugin="MyPlugin">
<description url="http://www.example.com/description">
</description>
<copyright url="http://www.example.com/copyright">
</copyright>
<license url="http://www.example.com/license">
</license>
<url>
<update label="Site do MyPlugin" url="http://example.org/myplugin"/>
</url>
<requires>
<import plugin="org.eclipse.ui" version="3.5.0" match="compatible"/>
<import plugin="org.eclipse.core.runtime" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.jface.text" version="3.8.0" match="compatible"/>
<import plugin="org.eclipse.core.resources" version="3.12.0" match="compatible"/>
<import plugin="org.eclipse.ui.editors"/>
<import plugin="org.eclipse.ui.views" version="3.8.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.jdt.ui" version="3.13.52" match="greaterOrEqual"/>
<import plugin="org.eclipse.jdt.core" version="3.13.50" match="greaterOrEqual"/>
</requires>
<plugin
id="MyPlugin"
download-size="0"
install-size="0"
version="0.4.0"
unpack="false"/>
</feature>
在feature.xml
中只能将自己的插件指定为<plugin ... />
,而不是需要的(Eclipse)plug-ins/bundles .
例如,
<plugin
id="org.eclipse.core.resources"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
使当前版本的plug-in/bundleorg.eclipse.core.resources
(version="0.0.0"
是一个占位符,在构建更新站点时将被当前版本替换)的一部分可以被安装。因为org.eclipse.core.resources
是一个单例plug-in/bundle(Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
),所以不能和其他版本的plug-in/bundle一起使用。这会阻止您的插件在许多 Eclipse 版本中部署。