简体   繁体   English

强制OSGi包由maven-bundle-plugin / BND导入

[英]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.

相关问题 这个“导入” maven-bundle-plugin OSGI警告是什么意思? - What does this “imported in” maven-bundle-plugin OSGI warning mean? 使用 maven-bundle-plugin 安装 OSGi 依赖项 - Installing OSGi dependencies with maven-bundle-plugin 是否可以使用maven-bundle-plugin(bnd)生成plugin.xml - Is it possible to use maven-bundle-plugin (bnd) to generate plugin.xml maven-bundle-plugin创建意外的导入包内容 - maven-bundle-plugin Creates unexpected Import-Package content 在maven-bundle-plugin中使用javax.servlet包 - use of javax.servlet package in maven-bundle-plugin maven-bundle-plugin不包含Import-Package - maven-bundle-plugin doesn't include Import-Package 为OSGI容器创建一个Web应用程序包(WAB),该容器不包含maven-bundle-plugin的所有依赖项jar - Create a Web Application Bundle (WAB) for a OSGI container that does NOT contain jar of all dependencies with maven-bundle-plugin maven-bundle-plugin嵌入依赖项无法将捆绑包部署到OSGi容器中 - maven-bundle-plugin embed dependency failed to deploy bundle into OSGi container OSGI捆绑包.bnd文件和冲突的导入包语句 - OSGI bundle .bnd file and conflicting import-package statements 如何在maven-bundle-plugin生成的Manifest中识别包版本的来源 - How to identify the source of a package version in the Manifest generated by maven-bundle-plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM