osgibndbndtoolsmaven-bundle-plugin

Why don't repositories in the bnd workspace model support transitive dependencies?


According to the Introduction to the bnd workspace model the repositories define and exact set of dependencies and not support transitive dependencies because they tend to make horrible OSGi systems.

Can someone provide a more detailed explanation (using concrete use cases is highly appreciated) when that is true? I guess this mainly related to the correct Import-Package list in the manifest. How transitive dependencies should be handled? Is there a way to provide all required imports?

Does that mean maven-only bundle development (with bnd-maven-plugin or maven-bundle-plugin) is more likely to be error-prone since maven does support transitive dependencies? How transitive dependencies should be handled in this case?

Thank you!


Solution

  • In OSGi bundle creation and application assembly are two very different things. When creating bundles with maven you of course use transitive dependencies. The result oft the maven-bundle-plugin or bnd-maven-plugin is entries in the jar Manifest. They define things like imported or exported packages. This result does not contain transitive dependencies. These bundles can be used in workspace model as well as maven model.

    The application assembly is a different process. There you build a so balled repository which is a list of possible bundles to install. In the workspace model you list each bundle without transitive dependencies. In the maven based application assembly you define the repository using the dependencies of a pom. There the transitive dependencies are used.

    The reason why transitive dependencies are not always good is that the dependencies of a bundle are often not the dependencies you want to use in your application. So the maven model has the potential of adding problematic bundles to the repository. These dependencies might then slow down to resolution of the actual bundles to use or even result in non working resolved bundles. Luckily you can fix this by excluding some of the transitive dependencies using the usual maven excludes.

    In my personal experience transitive bundles are often very useful for application assembly as you do not have to list all dependencies by hand. The problematic cases are not quite easdy to fix. So I do not agree that transitive dependencies should not be leveraged.