Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Choosing plugins to update with P2 and eclipse 4 programmatically
Choosing plugins to update with P2 and eclipse 4 programmatically [message #1771067] Mon, 21 August 2017 15:41 Go to next message
Diego Tavolaro is currently offline Diego TavolaroFriend
Messages: 6
Registered: August 2017
Junior Member
I would like to update a P2 repository with Eclipse 4 programmatically and I would like to choose plugins to update. Classic way to retrieve the provisioning job which updates the repository is:

ProvisioningSession session = new ProvisioningSession(agent);
UpdateOperation operation = new UpdateOperation(session);
operation.getProvisioningContext().setArtifactRepositories(new URI[] { uri});
operation.getProvisioningContext().setMetadataRepositories(new URI[] { uri});
IStatus status = operation.resolveModal(sub.newChild(100))
ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
IStatus st = provisioningJob.runModal(monitor);

The resolveModal method checks plugins to update. If I print the possible updates I will have only the product and not the plugins to update.
Update[] updates = operation.getPossibleUpdates();


Now, how to choose the plugins I would like to updates? The UpdateOperation object constructor allows me to specify a list of Installable Units, but if I exclude only the plugin I do not want, the system equally updates all the repository (because of product which is included in the list of installable units?).

Thank you.
Re: Choosing plugins to update with P2 and eclipse 4 programmatically [message #1771270 is a reply to message #1771067] Wed, 23 August 2017 15:16 Go to previous messageGo to next message
Eclipse UserFriend
Unless you've specifically crafted your product's requirements (via a p2.inf), your product is bound to exact versions of the specified features/plugins. Updating those referenced features requires updating the product too.

p2 does provide some support for prompting for selection of updates: see the `org.eclipse.equinox.p2.ui.ProvisioningUI#openUpdateWizard()` methods, and the `org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdater` class serves as a demonstration in action.

`ProvisioningUI` is based on Eclipse 3.x Workbench though. If you're building a pure E4 app, you'll need to roll your own. Or extract the JFace/SWT components from `org.eclipse.equinox.p2.ui`.
Re: Choosing plugins to update with P2 and eclipse 4 programmatically [message #1772671 is a reply to message #1771270] Wed, 13 September 2017 17:29 Go to previous messageGo to next message
Diego Tavolaro is currently offline Diego TavolaroFriend
Messages: 6
Registered: August 2017
Junior Member
Hi Brian,

no, I do not need UI. It is just the CheckUpdate function I would like to add to my application at startup without UI.
I would like to update some plugins at startup and eventually a last one when the application restarts (yes, updating twice :) ). To do that I would give the list of IUs to UpdateOperation, but it does not work. I cannot find anything on the net.
It is a E4 RCP application.

Thanks.

Re: Choosing plugins to update with P2 and eclipse 4 programmatically [message #1772974 is a reply to message #1772671] Tue, 19 September 2017 15:28 Go to previous message
Eclipse UserFriend
You'll need to use the lower-level APIs, involving IPlanner and IEngine. Here's a nice example of using the APIs:

https://github.com/adreghiciu/p2/blob/master/bundles/org.eclipse.equinox.p2.console/src/org/eclipse/equinox/internal/p2/console/ProvisioningHelper.java#L178

An update operation is an uninstall and install operation: you'll need to query your profile for the current version, find its replacement, and then configure the IProfileChangeRequest to remove the old IU and add the replacement IU.
Previous Topic:Installing a plugin-jar to an already existing/deployed RCP application
Next Topic:Toolbar Buttons Enablement problem
Goto Forum:
  


Current Time: Thu Apr 18 14:26:20 GMT 2024

Powered by FUDForum. Page generated in 0.03118 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top