Friday, March 27, 2009

How to update Eclipse plug-in in P2 world?

Well, before p2 it was pretty easy - one just had to drop updated plug-in into eclipse\plugins directory, and after restart (using -clean) updated plug-in was immediately there. Excelent for testing. Of course what you dropped manually, was then not possible to uninstall using Update Manager.

With p2 there's a few more steps required. If you can't make a feature update (which would be perfect solution), you need a feature patch, that will tell p2 that some plug-ins need an update. It's pretty easy with PDE Create Feature Patch wizard - only two things to take care about:
1. Make sure you know, which feature originally contributes a plug-in that you want to update.
This information can be found in Help>About Eclipse>Feature Details and by pressing "Plug-in details" at the bottom of the window.

2. Be careful with setting the host feature version.
Make sure that host feature version is general enough to work for all your clients. For example, setting version to 4.4.2.v123 won't work for users with feature 4.4.2.v125. Altough feature patch will install without single warning, plug-ins will not be updated. Setting 4.4 instead will work for both 4.4.2.v123 and 4.4.2.v123 as well as any other 4.4.x.x versions.

Does anyone know if feature patches support version ranges?

Bonus: now user can easily install/uninstall the update in p2 UI without messing with files. Yuppi!

Couple more questions: what happens if there's more than one patch for a single feature? What if after applying a patch, feature is updated to version that still matches the patch?

ps. for those who know I don't read Eclipse tips - yes this is Eclipse tip, but while I do at least 1 patch per month, figuring out everything from scratch gets boring after some time :-P

1 comment:

Jacek Pospychala said...

ps2. copying files like in classical UM scenario, but to dropins also won't work. That's because plugins managed by p2 have precedence over anything in dropins.