0

I am looking for a way to ensure that all the features I deploy in Karaf require dependencies that are of the same version. The project is composed of more than 40 bundles which makes it difficult to verify manually.

I am thinking of developping a Maven plug-in that would make the check, but before I would like to be sure that such a solution do not exist yet.

Oleg
  • 161
  • 1
  • 14

2 Answers2

1

If you want to be sure you use the same versions then create a parent project and define versions of dependencies only there. So you can be sure all your modules have the same dependencies. Of course this only makes sense if all these modules are very closely related (e.g. belong to the same application / release unit).

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • no they are not :) that's why I'm looking for a more sophisticated system – Oleg Aug 07 '15 at 14:33
  • If they are not closely related then you should not enforce that they require the same dependencies. It would create a tight coupling between the components that will give you a lot of headaches. Instead use the flexibility OSGi provides and use import ranges. Btw. Karaf also allows import ranges on features which might help. – Christian Schneider Aug 08 '15 at 10:41
1

Why would you even want to do this? Each bundle should depend on the versions of the package it needs, and that dependency should be a range. So if you compile against and API package version 1.0.0, and you are a consumer of that API, then you should import with the range [1.0.0, 2.0.0). Refer to the OSGi Core Release 5 specification, section 3.7.3 ("Semantic Versioning") for details.

At runtime the OSGi Framework will ensure that your bundle is wired to a package version that is within its permitted range. Obviously if you have non-overlapping version ranges from different importers then the Framework will not be able to satisfy them with a single exporter.

Neil Bartlett
  • 23,743
  • 4
  • 44
  • 77