4

我有OSGI一个依赖于第 3 方库的包,我不想在容器中部署该库,我宁愿将它嵌入到我的包中。

当然,那个库有它自己的依赖,我也想嵌入它们。

我正在使用Maven Bundle Plugin

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
   <configuration>
     <instructions>
        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
        <Bundle-Description>${project.description}</Bundle-Description>
        <Bundle-Vendor>${bundle.vendor}</Bundle-Vendor>
        <Meta-Persistence>...</Meta-Persistence>
        <Export-Package>...</Export-Package>
        <Import-Package>...</Import-Package>
        <Embed-Dependency>3rd-Party</Embed-Dependency>                      
        <Embed-Transitive>true</Embed-Transitive>
      </instructions>
    </configuration>
</plugin>

结果,3rd-Party嵌入在结果包中,但不是它的传递依赖项,好像<Embed-Transitive>true</Embed-Transitive>没有任何效果。

所以我有一些问题

  • 这是以传递方式嵌入 3rd 方库的正确方法吗?
  • 这是否会处理生成的清单文件(不导入属于 3rd 方库及其依赖项的包)?

谢谢

4

1 回答 1

1

About Embed-Dependency: If you take a look at the felix docs they always use a scope like: ;scope=compile|runtime.

Maybe the names of the dependent bundles must also fit the regex given. If you want to embed most of the jars and only omit a few than maybe you can embed * and then exclude some with !.

About the Manifest: The maven bundle plugin should take care of adapting the imports to your embedded packages. So there should not be imports for packages that are embedded.

于 2017-03-10T10:43:33.127 回答