Thanks Mickael for the clue!
I finally been able to get it working thanks to stuff in
ProvisioningOperationRunner.requestRestart(...)
Sharing hereafter the raw code of my snippet in case it can helps in the
future, the 2 missing lines were those about Policy.RESTART_POLICY_FORCE_APPLY.
ProvisioningUI ui = ProvisioningUI.getDefaultUI();
InstallOperation installOperation = ui.getInstallOperation(toInstall,
repositories);
IStatus status = installOperation.resolveModal(monitor);
if (status.isOK()) {
ProvisioningJob job = installOperation.getProvisioningJob(monitor);
ui.getPolicy().setRestartPolicy(Policy.RESTART_POLICY_FORCE_APPLY);
ui.manageJob(job, Policy.RESTART_POLICY_FORCE_APPLY);
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
Bundle bundle = Platform.getBundle(...);
if (bundle != null) {
bundle.start();
}
}
}
});
job.setUser(user);
job.schedule();
}
/Julien
From: [email protected] <[email protected]> On Behalf Of
Mickael Istria
Sent: vendredi 17 janvier 2020 09:37
To: P2 developer discussions <[email protected]>
Subject: Re: [p2-dev] Complete installation without restart
On Fri, Jan 17, 2020 at 9:29 AM Julien DEHAUDT
<[email protected]<mailto:[email protected]>> wrote:
Hi gents,
Hi,
I’m wondering if there is a way to force the enablement of a plugin freshly
installed without restarting Eclipse?
It's possible using p2 APIs. However, not something I can remember now.
I’ve already read:
https://wiki.eclipse.org/FAQ_What_is_a_dynamic_plug-in%3F
https://wiki.eclipse.org/FAQ_How_do_I_make_my_plug-in_dynamic_aware%3F
https://wiki.eclipse.org/FAQ_How_do_I_make_my_plug-in_dynamic_enabled%3F
But I’m not sure this doc is up-to-date with recent Eclipse versions.
They're indeed outdated. What can make a plugin dynamic enough is mostly
whether the extension point provider (the plugin that defines the extension
point and reads the extension) does implement listening to change in the
extension registry. Same thing for loading services from context or OSGi
(although I believe OSGi does natively has dynamism for services).
I remember that in the past there was an “Apply changes” button after an
installation, this is somehow what I try to restore for a specific installation.
Beware this was removed because in many cases, the result was incomplete or not
satisfying: old extensions where remaining and failing, new ones ignored
(because some plugins only look at extension registry once). Those are issues
that would be relatively hard to avoid, so be careful.
Installation already done programmatically (feature well installed if I restart
the rcp), I’m just missing the last rocket floor ☺
I don't recall the exact API. I suggest you look at the history of the
installation complete notification dialog, find a version when "Apply" was
still here and then see what it was bound to.
HTH
_______________________________________________
p2-dev mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://www.eclipse.org/mailman/listinfo/p2-dev