Search code examples
dependenciesosgimaven-pluginapache-felixosgi-bundle

Can I declare a dependency like private package using Apache Felix Maven Bundle Plugin?


Can I declare a dependency like private package using Apache Felix Maven Bundle Plugin?

I would like to avoid NoClassDefFoundException due to different version of a transitive dependency.

Following Apache Felix Maven Bundle Plugin documentation I can see <Private-Package>org.apache.felix.log.impl</Private-Package>, but in that example the dependency which is declared as private is an own class.

I do not know if that statement could work with a dependency.


Solution

  • You can use Private-Package for a package that is located inside a dependency. The result will be that the content of the package is embedded into your bundle.

    Be careful though as this will cause Import-Package statements for all of the imports of all classes in this package. So in effect in can make your situation even worse.