Forced OSGi package for import via maven-bundle-plugin / BND

I am trying to package an OSGI package using the maven-bundle-plugin module (which uses BND).

To work correctly, a package must import a package that is not in the classpath at design time (since object references will be passed to the binding methods as class references).

I cannot configure the Import-Package declaration in the pom.xml or * .bnd file so that the package is included in the OSGI Import-Package in MANIFEST. I though

Import-Package: de.foo.bar,* 

should complete the task, but since de.foo.bar is not in the classpath (or better not declared as import in code), it will not be sent to MANIFEST.

Does anyone know how to force a package to be available in a MANIFEST declaration in OSGi Import-Package.

Thank you and welcome Klaus

+4
source share
1 answer

Finally I found a solution

 Import-Package: de.foo.bar;resolution:=optional,* 

will put "de.foo.bar" in the Import-Package declaration of the MANIFEST.MF package, even if the package is not imported by the package code.

+3
source

Source: https://habr.com/ru/post/1313535/


All Articles