Question

Is there any relationship between the bundles mentioned in the <dependencies> tag and the <Import-Package> tag? I mean if we don't define dependency, then maven-bundle-plugin can not find the packages in <Import-Package> tag?

Was it helpful?

Solution

Maven uses the jars listed in the dependencies section to create a classpath. This class path is used by bnd (the engine in the maven bundle plugin) to analyze what your code is referring to through byte code analysis.

 maven dependency -> classpath -> bnd analysis -> import statements

OTHER TIPS

Import-Package is used to refine the list of package imports which the maven bundle plugin generates automatically for you. For example, you could declare some imports optional, or add imports for classes which are only accessed by reflection. In most cases it shouldn't be necessary to specify anything at all for Import-Package since the default is * - that is, any external packages referenced in your bytecode will be imported.

The dependencies section provides the pool of bundles used by the compiler to generate the bytecode, and bnd (which is what the bundle plugin under the covers) to improve the package imports. For example, it will add version ranges based on the exported versions in a providing bundle in the dependencies list (or in transitive dependencies).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top