Eri*_* B. 5 osgi eclipse-plugin maven apache-felix
我遇到了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)"
Run Code Online (Sandbox Code Playgroud)
但我需要它来生成:
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
我的插件配置是:
<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>
Run Code Online (Sandbox Code Playgroud)
如果我尝试加载版本,我会收到以下错误:
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)
Run Code Online (Sandbox Code Playgroud)
添加version=!在Import-Package从部分到每一个省略的版本,你要束的会做的伎俩。
<Import-Package>
com.ghc.ghTester.expressions;version=!,
org.apache.ws.security.processor;version=!,
org.apache.ws.security;version=!,
org.apache.ws.security.message;version=!,
org.apache.ws.security.components.crypto;version=!,
org.apache.ws.security.message.token;version=!,
*
</Import-Package>
Run Code Online (Sandbox Code Playgroud)
您可以开始手动编写导入,就像使用“com.ghc.ghTester.expressions”一样
<Import-Package>
com.ghc.ghTester.expressions,
org.apache.ws.security.processor,
org.apache.ws.security,
org.apache.ws.security.message,
org.apache.ws.security.components.crypto,
org.apache.ws.security.message.token
</Import-Package>
Run Code Online (Sandbox Code Playgroud)
尽管这不是评论中提到的好做法,但它应该可以解决问题。但如果您稍后需要额外的导入,您也必须手动添加它们。
顺便一提。的值
<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Version>${pom.version}</Bundle-Version>
Run Code Online (Sandbox Code Playgroud)
默认为您提供的值。请参阅http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html 部分:默认行为
| 归档时间: |
|
| 查看次数: |
3642 次 |
| 最近记录: |