OSGI nested dependency jars

2019-07-19 05:40发布

问题:

If I have a OSGI Bundle that has dependency jars nested inside the OSGI Bundle jar, do I need to list those classes in the Import-Package manifest so that I could use them? I would think not.

Also how do I add these dependency jars into my bundle. Do I just put them in the root folder? Do I need to add anything to the manifest file to be able to use these dependencies?

回答1:

You should not use Import-Package for embedded jars. Instead use Bundle-ClassPath: .,myjar.jar to add the embedded jars to the bundle classpath.



回答2:

Avoid using Bundle-ClassPath manually. You can use maven-bundle-plugin to solve and embed your third party dependencies like this:

<plugins>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<extensions>true</extensions>
<configuration>
    <instructions>
    <Bundle-SymbolicName>${project.artifactId};singleton:=true</Bundle-SymbolicName>
    <Bundle-Version>${project.version}</Bundle-Version>
    <Export-Package>lumina.extensions.drivers.luminadb</Export-Package>
    <Bundle-Activator>lumina.extensions.drivers.luminadb.internal.Activator</Bundle-Activator>
    <Embed-Dependency> YOUR ARTIFACT ID HERE </Embed-Dependency>
    </instructions>
</configuration>
</plugin>
(...)

</plugins>

For more information visit http://web.ist.utl.pt/ist162500/?p=110



标签: osgi