如何使Eclipse插件可部署在许多Eclipse版本中? [英] How to make a Eclipse plug-in deployable in many Eclipse versions?
问题描述
我为Eclipse Oxygen 3a编写了自己的Eclipse插件.它可以在Eclipse Oxygen 3a中完美运行.
I wrote my own Eclipse plug-in for Eclipse Oxygen 3a. It works perfectly in Eclipse Oxygen 3a.
现在需要在较新版本的Eclipse中部署相同的插件,但是当将插件安装在Eclipse Photon中时,安装窗口会显示:
Now I'm being required to deploy the same plug-in in newer versions of Eclipse, but when the plug-in is being installed in, for instance, Eclipse Photon, the install window says:
Cannot perform operation. Computing alternate solutions, may take a while: ...
确实花了很长时间,最终说我的插件无法安装.
It indeed takes a long while and ends up saying that my plug-in will not be installed.
如何使该插件可用于多个Eclipse版本?
What to do to make this plug-in workable to more than one Eclipse version?
根据要求,这是Require-Bundle:
As asked, this is the 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"
没有导入包.
feature.xml文件如下所示.我在内部Apache Web服务器中部署了一个插件站点,并使用Eclipse的帮助"菜单中的安装新软件"选项从thare安装.
The feature.xml file can be seen below. I have a plug-in site deployed in an internal Apache web server and use "Install new software" option in Help menu of Eclipse to install from 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
修复窗口:
尝试在Eclipse JEE 2019-Jul中安装插件失败后,我收到以下错误消息:
After the unsuccessful atempt to install the plug-in in Eclipse JEE 2019-Jul I had the following error message:
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文件:
Update 5
IN the feature editor I decided to click the [Compute] button and all the dependencies were recomputed. As a result below we have the new feature.xml file:
<?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)插件/捆绑包.
In feature.xml
only your own plug-ins should be specified as <plugin ... />
, not the (Eclipse) plug-ins/bundles that are required.
例如,
<plugin
id="org.eclipse.core.resources"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
使当前版本的插件/捆绑包 org.eclipse.core.resources
( version ="0.0.0"
是一个占位符,将被替换)在构建更新站点时由当前版本决定)可以安装的东西的一部分.因为 org.eclipse.core.resources
是单例插件/捆绑包( Bundle-SymbolicName:org.eclipse.core.resources; singleton:= true
),所以它不能与其他版本的插件/捆绑包一起使用.这样会阻止您的插件在许多Eclipse版本中进行部署.
makes the plug-in/bundle org.eclipse.core.resources
of the current version (version="0.0.0"
is a placeholder that will be replaced by the current version when building the update site) part of the thing that can be installed. Because org.eclipse.core.resources
is a singleton plug-in/bundle (Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
), it cannot be used with the plug-in/bundle of another version. This prevents your plug-in from being deployable in many Eclipse versions.
这篇关于如何使Eclipse插件可部署在许多Eclipse版本中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!