Вопрос

I am wondering can bnd 2.1.0 generate manifest where in Import-Package: we have two packages with the same name but with different versions. Is it possibly and is there sense in this action? Import-Package: 'com.sample.logger;version="1.0.0",com.sample.logger;version="[2,3)"'

Это было полезно?

Решение

If it was possible, how could your program ever decide which package to use? Moreover, the version ranges in your example is distinct, basically you are requiring the com.sample.logger package to have a version equal to 1.0.0 and to be bigger or equal to 2 and less than 3 at the same time.

What is possible and valid, however, is to have multiple bundles exporting the same package in different versions, say 1.2.3 and 2.0.0. Another bundle, requiring this package, can define the exact version it needs (or a version range of course) in its Import-Package statement. Like this the OSGi framework can make sure that the wiring between bundles is correct.

Like this, for example, you could use both an old version of your bundle and a newer one at the same time without any problem (what you could never do with a 'flat' classpath like in non-OSGi java).

Maybe this is what you meant?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top