Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » P2 » Choosing plugins to update programmatically
Choosing plugins to update programmatically [message #1772891] Mon, 18 September 2017 12:57 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.

IProfile self = profileRegistry.getProfile(IProfileRegistry.SELF);
IQuery<IInstallableUnit> query = new UserVisibleRootQuery();
IQueryResult<IInstallableUnit> roots = self.query(query, null);
Set<IInstallableUnit> iiu = roots.toUnmodifiableSet();
if (iiu != null) {
	for (IInstallableUnit i : iiu) {
				logger.info("NAME: " + i.getId() + " - VERSION: " + i.getVersion().toString());
	}
}


What I have from this code, that should search for available updates in all the repository is the only product, with version with timestamp changed (everytime I build with Tycho I have a new version 1.0.0.<timestamp>).

The application performs a simple check of the available updates. I do not need UI to do that.

What am I wrong ?

Thank you.

[Updated on: Mon, 18 September 2017 13:04]

Report message to a moderator

Re: Choosing plugins to update programmatically [message #1772907 is a reply to message #1772891] Mon, 18 September 2017 15:04 Go to previous messageGo to next message
Diego Tavolaro is currently offline Diego TavolaroFriend
Messages: 6
Registered: August 2017
Junior Member
Hi again,

moreover I tried this piece of code (just trying if with this piece of code P2 is able to understand to update just this feature and not everything):

ProvisioningSession session = new ProvisioningSession(agent);
IProfile profile = profileRegistry.getProfile(IProfileRegistry.SELF);
query = QueryUtil.createLatestQuery(QueryUtil.createIUQuery("Feature_VersionGreen.feature.group"));
final IQueryResult<IInstallableUnit> result = profile.query(query, new NullProgressMonitor());
UpdateOperation operation = new UpdateOperation(session, result.toSet());
IStatus status = operation.resolveModal(monitor);


And I have this error message:

2017-09-18 16:40:45,384 ERROR       s.CheckUpdates - UpdateStatus : Operation details
2017-09-18 16:40:45,384 ERROR       s.CheckUpdates - UpdateStatus : Cannot complete the install because of a conflicting dependency.
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Software being installed: Feature_VersionGreen Feature 3.1.15 (Feature_VersionGreen.feature.group 3.1.15)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Software currently installed: GreenProduct 1.0.0.201709181430 (GreenProduct.product 1.0.0.201709181430)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Only one of the following can be installed at once: 
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Feature_VersionGreen Feature 3.1.14 (Feature_VersionGreen.feature.jar 3.1.14)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Feature_VersionGreen Feature 3.1.15 (Feature_VersionGreen.feature.jar 3.1.15)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Cannot satisfy dependency:
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : From: Feature_VersionGreen Feature 3.1.14 (Feature_VersionGreen.feature.group 3.1.14)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : To: Feature_VersionGreen.feature.jar [3.1.14]
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Cannot satisfy dependency:
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : From: Feature_VersionGreen Feature 3.1.15 (Feature_VersionGreen.feature.group 3.1.15)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : To: Feature_VersionGreen.feature.jar [3.1.15]
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : Cannot satisfy dependency:
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : From: GreenProduct 1.0.0.201709181430 (GreenProduct.product 1.0.0.201709181430)
2017-09-18 16:40:45,385 ERROR       s.CheckUpdates - UpdateStatus : To: Feature_VersionGreen.feature.group [3.1.14]


I do not know if this can help... Probably I am missing something.

Thank you for your precious help.
Re: Choosing plugins to update programmatically [message #1772969 is a reply to message #1772907] Tue, 19 September 2017 15:11 Go to previous message
Eclipse UserFriend
There are some methods on ProvisioningUI for opening wizards for selection, IIRC.
Previous Topic:Install plug-in without resolving dependencies
Next Topic:My RCP does not detect updates from my update site
Goto Forum:
  


Current Time: Thu Nov 07 20:05:51 GMT 2024

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

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

Back to the top