5

I'm trying to apply a patch to an existing plug-in using a fragment plugin as described here:

Steps to use Fragments to patch a plug-in - Eclipsepedia

The patch to the host plugin involves replacing a single class file with an updated class file. But I don't get the concept in section Modify the Host package Manifest settings steps 5) to 11). Here it instructs you to modify the host plugin. I thought the whole idea is that you don't have to touch the host plugin - its the fragment that you deploy that adds the patch?

My product consists of eclipse platform and org.eclipse.cdt features plus my own plugins that use cdt. It is the org.eclipse.cdt.core plugin that I would like to patch.

I've followed the steps in the eclipse wiki and created my fragment project containing the package and class I want to patch in the host plugin. I've built this in maven and when I run this product I see my fragment plugin is active, but the class it contains is not getting called; the original host plugin class is.

I'm guessing the problem is that the modified host plugin is not in my deployed product. There aren't any steps included in the fragment guide on advice for deploying the host plugin and I'm not sure how/why it is necessary.

(I've used a feature patch successfully in the past for this sort of thing, but only created using the PDE - I couldn't get my feature patch to build under maven - that's why I'm exploring the use of fragments to see if I can get them to build under maven.)

UPDATE*: I create my build using the Tycho plugin to Maven Tycho - Building Eclipse plug-ins with maven.

Thanks for linking to "OSGi Core Release 5 Specification". That was useful reading.

So if my understanding is correct a fragment can only overlay its class over the host plugin's if the host plugin has already been "prepared" to be patched with a fragment. This involves modifying the host plugin's manifest. Specifically: 1. add a new library and move that above '.' package. Remove this library from the build properites; the library is just a reference and should not be created by the host plugin. + add Eclipse-ExtensibleAPI: true to the manifest.mf file + bump the version number.

In my case, it seems, if I wanted to patch the org.eclipse.cdt.core plugin using a fragment I would have to deliver the prepared version of the org.eclipse.cdt.core plugin plus my fragment plugin.

*: not sure on answering etiquette; don't have enough reputation to do many things. Comment box only accepts a small number of chars.

betamax
  • 116
  • 1
  • 9
  • It would definitely be necessary to include the modified host plugin. As I don't use maven I don't know how you would go about that. – greg-449 Oct 10 '14 at 07:40
  • I think you're right. However, I did manage to use a fragment to patch SWT (https://www.eclipse.org/swt/faq.php#specifyxulrunner) without modifying the host plugin. I expect this is because the SWT plugin already expects to be patched? – betamax Oct 17 '14 at 10:02

1 Answers1

0

There's a more intuitive explanation (at least for me) on OSGi Fragment bundle level that basically shows the result of what is achieved by the GUI operations in Eclipse. According to this the Bundle-ClassPath in the host's manifest has to be adapted if you want to replace, or better: overlay, an existing class.

See also OSGi Core Release 5 Specification, 3.14 Fragment bundles, p.69 ff for details.

You created your bundle with the Maven Bundle Plugin, did you?

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107