3

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?

user1159819
  • 1,549
  • 4
  • 16
  • 29

2 Answers2

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

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
PedroD
  • 5,670
  • 12
  • 46
  • 84
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.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • thanks. What if I explode those jars and then copy them into my bundle jar, do I still need to put anything in the manifest? – user1159819 Aug 11 '14 at 13:41
  • In this case you do not need any special settings. You can do this with the maven bundle plugin. If you specify packages as private that are not already present locally then they are embedded from the maven dependencies. So they end up inside your bundle as .class files. – Christian Schneider Aug 12 '14 at 06:47