What does the private-package manifest header do?

前端 未结 3 1920
忘了有多久
忘了有多久 2021-02-19 15:57

I am familiar with Import-Package and Export-Package, but this is a new one for me. What does it do?

3条回答
  •  醉梦人生
    2021-02-19 16:32

    At runtime in the OSGi container it does nothing. In fact, it's not even mentioned in the OSGi specification (I checked R4).

    However, it can be specified in a .bnd file for use by bnd at build time. If so, it can be used to determine what goes into the bundle. When bnd builds a bundle, it automatically determines which classes need to go into the bundle. All the classes in packages that are exported are included, and all the classes that they depend on (transitively) are included too. This means that if a class doesn't appear to be used, then it won't be included in the bundle. However, you can use the Private-Package instruction to tell bnd to include the contents of the package in the bundle, even if it appears to be unused. If the Private-Package instruction is not specified, then it will be automatically generated by bnd.

    The documentation for Private-Package reads as follows:

    Private Package

    The method of inclusion is identical to the Export-Package header, the only difference is, is that these packages are not exported. This header will be copied to the manifest. If a package is selected by noth the export and private package headers, then the export takes precedence.

    Private-Package= com.*

提交回复
热议问题