How to make a Eclipse plug-in deployable in many Eclipse versions?

别来无恙 提交于 2021-02-11 10:12:51

问题


I wrote my own Eclipse plug-in for Eclipse Oxygen 3a. It works perfectly in Eclipse Oxygen 3a.

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.

What to do to make this plug-in workable to more than one Eclipse version?

Update 1

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"

There is no Import-Bundle.

Update 2

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>

Update 3

Remediation window:

Update 4

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]

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>

回答1:


In feature.xml only your own plug-ins should be specified as <plugin ... />, not the (Eclipse) plug-ins/bundles that are required.

For example,

    <plugin
         id="org.eclipse.core.resources"
         download-size="0"
         install-size="0"
         version="0.0.0"
         unpack="false"/>

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.



来源:https://stackoverflow.com/questions/60060807/how-to-make-a-eclipse-plug-in-deployable-in-many-eclipse-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!