[英]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). 我尝试使用maven-bundle-plugin(使用BND)打包OSGI包。
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). 要正确运行,bundle必须在开发期间导入一个不在类路径中的包(因为对象引用将作为“Class”引用传递给bundle方法)。
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. 我无法在pom.xml或* .bnd文件中配置“Import-Package”声明,以便packe将包含在MANIFEST的OSGI Import-Package部分中。 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. 应该做的工作,但由于de.foo.bar不在类路径中(或者最好不在代码中声明为导入),它将不会被带到MANIFEST。
Has anybody an idea how to force the package to be available in the OSGi Import-Package MANIFEST declaration. 有没有人知道如何强制在OSGi Import-Package MANIFEST声明中提供包。
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. 将“de.foo.bar”放在捆绑MANIFEST.MF的“Import-Package”声明中,即使捆绑包代码未导入包也是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.