简体   繁体   中英

Force OSGi package to be imported by maven-bundle-plugin / BND

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

To run properly the bundle must import a package which is not in the classpath during development (because object references will be passed to the bundle methods as "Class" references).

I do not manage to configure the "Import-Package" declaration in the pom.xml or *.bnd file so that the packe will be included in the OSGI Import-Package part of the MANIFEST. I though

Import-Package: de.foo.bar,*

should do the job, but as de.foo.bar is not in the classpath (or better not declared as an import in the code) it will not be taken to the MANIFEST.

Has anybody an idea how to force the package to be available in the OSGi Import-Package MANIFEST declaration.

Thanks and regards Klaus

I finally found a solution

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM