How to advise p2 to add a repository during feature installation in case a dependency of the feature is not yet installed?

StackOverflow https://stackoverflow.com/questions/13268960

  •  27-11-2021
  •  | 
  •  

Question

I am designing an Eclipse feature that contains bundles that require dependencies that may be present in the installation target, but this is not necessarily the case. I would like to avoid the installation of unnecessary IUs. I would like to know how to advise the p2 installer that I would like a feature installed only if required IUs are not present in the installation and provide the repository location to download the IUs from.

The desired scenario for a main IU M that depends on an IU D would be:

  1. p2 attempts install of M, finds that it requires D
  2. p2 finds that D is missing in the current installation
  3. Based on the installation advice, p2 obtains D from the repository URL associated with D
  4. p2 installs D
  5. p2 installs M
Was it helpful?

Solution

AFAIK, it is neither possible to

  • conditionally add a p2 repository only if a dependency is not satisfied, nor
  • add a p2 repository before an installation - you can only add p2 repositories e.g. during the installation of a feature, which then may be used in the next operation, e.g. an update.

However you can achieve your use case by including the p2 repository with the dependencies of your feature in your own p2 repository.

Technically, there are different solutions to this, but the simplest one is probably to create a so-called "composite repository" that includes both the repository with your own content, as well as the repositories with the external dependencies.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top