问题描述
我在maven-bundle-plugin生成的MANIFEST.MF中遇到麻烦。由于某些原因,当我有< Import-Package>
字段中列出的版本号时,OSGi框架不会加载我的包。 我已经尝试并注意到,如果我删除了清单中的版本号,那么捆绑包正确加载。
我指示maven-bundle-plugin跳过版本号?
目前,它生成:
Import-Package:com.ghc.ghTester.expressions,org.apache.ws.security.proc
essor; version =[1.5,2),org.apache.ws。 security; version =[1.5,2),org.ap
ache.ws.security.message; version =[1.5,2),org.apache.ws.security.compo
nents.crypto; version =[1.5,2,org.apache.ws.security.message.token; ver
sion =[1.5,2)
但是我需要它来生成:
Import-Package:com.ghc.ghTester .expressions,org.apache.ws.security.proc
essor,org.apache.ws.security,org.apache.ws.security.message,org.apa澈。
ws.security.components.crypto,org.apache.ws.security.message.token
我的插件配置是:
< plugin>
< groupId> org.apache.felix< / groupId>
< artifactId> maven-bundle-plugin< / artifactId>
< version> 3.0.0< / version>
< extensions> true< / extensions>
< configuration>
<指令>
< Bundle-SymbolicName> $ {pom.groupId} $ {pom.artifactId}; singleton:= true< / Bundle-SymbolicName>
< Bundle-Name> $ {pom.name}< / Bundle-Name>
< Bundle-Version> $ {pom.version}< / Bundle-Version>
< Bundle-ClassPath> {maven-dependencies},。< / Bundle-ClassPath>
< Embed-Dependency> *; scope = compile< / Embed-Dependency>
< Export-Package /> <! - 此捆绑包无需导出 - >
< Import-Package> com.ghc.ghTester.expressions,org.apache.ws。*< / Import-Package>
< / instructions>
< / configuration>
< / plugin>
如果我尝试加载版本,我会收到以下错误:
org.osgi.framework.BundleException:无法解析模块:com.rit.message-level-security [978]
未解决的要求:导入包:org.apache.ws.security; version =[1.0.0,3.0.0
在org.eclipse.osgi.container.Module.start(Module.java:434)
在org.eclipse.osgi .internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
在org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
at com.ghc.ghTester .Activator.installTempBundle(Activator.java:157)
您可以使用以下配置来禁用默认的 Import-Package
版本:
< _消费政策> $ {范围; [ - ,++)}< / _消费者的策略>
I'm having trouble with the MANIFEST.MF generated by the maven-bundle-plugin. For some reason, when I have the version numbers listed in the <Import-Package>
field, the OSGi framework doesn't load my bundle.
I've experimented and noticed that if I remove the version numbers in the manifest, then the bundle is properly loaded.
How can I instruct maven-bundle-plugin to skip the version numbers?
Currently, it generates:
Import-Package: com.ghc.ghTester.expressions,org.apache.ws.security.proc
essor;version="[1.5,2)",org.apache.ws.security;version="[1.5,2)",org.ap
ache.ws.security.message;version="[1.5,2)",org.apache.ws.security.compo
nents.crypto;version="[1.5,2)",org.apache.ws.security.message.token;ver
sion="[1.5,2)"
But I need it to generate:
Import-Package: com.ghc.ghTester.expressions,org.apache.ws.security.proc essor,org.apache.ws.security,org.apache.ws.security.message,org.apache. ws.security.components.crypto,org.apache.ws.security.message.token
My plugin config is:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId};singleton:=true</Bundle-SymbolicName>
<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Version>${pom.version}</Bundle-Version>
<Bundle-ClassPath>{maven-dependencies},.</Bundle-ClassPath>
<Embed-Dependency>*;scope=compile</Embed-Dependency>
<Export-Package/> <!-- nothing for this bundle to export -->
<Import-Package>com.ghc.ghTester.expressions,org.apache.ws.*</Import-Package>
</instructions>
</configuration>
</plugin>
If I try loading it with the version, I get the following error:
org.osgi.framework.BundleException: Could not resolve module: com.rit.message-level-security [978]
Unresolved requirement: Import-Package: org.apache.ws.security; version="[1.0.0,3.0.0)"
at org.eclipse.osgi.container.Module.start(Module.java:434)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:393)
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:412)
at com.ghc.ghTester.Activator.installTempBundle(Activator.java:157)
You can disable default Import-Package
versions using the following configuration:
<_consumer-policy>${range;[--,++)}</_consumer-policy>
这篇关于如何使用maven-bundle-plugin从Import-Package中排除版本号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!