-
-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
conditionalpackage should overrule exportcontents #3721
Comments
These instructions are processed at different phases in the build and are orthogonal in purpose. Conditional package is about populating the jar contents (to later avoid importing packages). Export contents is about calculating the manifest's Export-Packages header. Also, there may be developers who depend upon the current behavior and would break in your requested behavior change. I am not sure using Since you know the package pattern for conditionally added packages, you could exclude that pattern from the export contents.
|
Ok, I see. But since https://bnd.bndtools.org/instructions/conditionalpackage.html explicitly states
at least a WARNING from bnd would be very helpful in that case. |
The doc is giving advice to you, the reader. It is expressing the intent of conditional package which is to replace an import of a package with a private copy of a package. And since the copy of the package is meant to be private to the bundle, the bundle should really not be exporting it. But hey, you are the developer and can do a crazy thing if you want! :-) I agree the doc should be more precise and helpful here. Can you make a PR? |
@bjhargrave Actually your workaround does not work in bnd 4.3.1
will still export foo! You can reproduce with the slightly more complex example at https://github.com/apache/sling-org-apache-sling-installer-core/tree/feature/new-parent. |
It turns out the correct solution is
This says to export all versioned packages except those which are conditionally added. (It turns out Bnd already knows which packages are conditionally added. Bnd has so many features I can't sometimes remember them all!) Also, your bnd.bnd file is weird in that it has two backslashes at the end of each line instead of the single backslash used to indicate line continuation. And this line has a line continuation (albeit a double backslash again) which adds what you intended to be a comment line to the end of the So your bnd.bnd file should look like: -conditionalpackage: org.apache.felix.configurator.impl.*,\
org.apache.sling.feature.io.*,\
javax.json.*,\
org.apache.johnzon.core.*,\
org.apache.felix.converter.*,\
org.apache.felix.cm.*,\
org.apache.sling.commons.osgi.*
-exportcontents: ${removeall;${packages;VERSIONED};${packages;CONDITIONAL}}
Provide-Capability: osgi.service;objectClass:List<String>="org.apache.sling.installer.api.OsgiInstaller,org.apache.sling.installer.api.ResourceChangeListener,org.apache.sling.installer.api.info.InfoProvider,org.apache.sling.installer.api.tasks.RetryHandler",\
osgi.service;objectClass:List<String>="org.apache.sling.installer.api.event.InstallationListener,org.apache.sling.installer.api.jmx.InstallerMBean"
|
@bjhargrave Thanks a lot. The |
@bjhargrave Is there a similar macro to not export packages being embedded via Update: As there is nothing documented in https://bnd.bndtools.org/macros/packages.html I raised #4219. |
Hi team I had one problem |
Currently in the global parent pom I use the instruction
Unfortunately that will lead to also exporting packages being embedded via
-conditionalpackage
. That is not intended. How can I exclude certain packages from being exported while keeping the global/inherited-exportcontents: ${packages;VERSIONED}
?IMHO all packages being embedded via
-conditionalpackage
should be excluded from being exported, no matter whether the package is versioned or not.The text was updated successfully, but these errors were encountered: