-
-
Notifications
You must be signed in to change notification settings - Fork 302
Prevent generating import-package version ranges for unstable API #6702
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
base: master
Are you sure you want to change the base?
Prevent generating import-package version ranges for unstable API #6702
Conversation
16b2fca
to
5b35184
Compare
Looks good to me. The only thought I have is wether this warning should be always emitted (like you have it now) or only with -pedantic: true. Furthermore: Where could this behavior be described in the docs. Maybe somewhere here? |
There is already some functionality which prints warnings about missing versions on import-package headers: bnd/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java Lines 2130 to 2132 in e517467
-pedantic: true . I am gonna rework my patch to not emit any warning and just rely on the existing logic for the warning. However this warning does not indicate why the version range is missing....
|
After having a 2nd thought I would rather prefer to always emit a warn when importing unstable API (not only with pedantic). This is different from the case where you explicitly import a package without a version when bnd cannot find any matching dependency in the classpath. I will just look into preventing the duplicate warning when depending on unstable API. WDYT @chrisrueger |
How about leaving the range as-is and instead you could add package-level versioning to your exports? That way, if a consumer of your artifact upgrades from 0.x to 1.x, they may still get package-level 0.x compatibility - wouldn't that resolve the issue as well? Alternatively, you could explicitly export using |
5b35184
to
b9a1a8e
Compare
I would argue that version ranges are not useful for unstable API (not complying with semantic versioning) in almost all of the cases. Rather generating a version range for unstable APIs should be a manual thing (as this would be special and cannot be derived from semantic versioning rules), but the default should be no restriction. |
This closes bndtools#6701 Signed-off-by: Konrad Windszus <[email protected]>
b9a1a8e
to
9fc763d
Compare
@@ -2117,7 +2126,7 @@ void augmentImports(Packages imports, Packages exports) throws Exception { | |||
|
|||
String result = importAttributes.get(Constants.VERSION_ATTRIBUTE); | |||
if ((result == null || !Verifier.isVersionRange(result)) | |||
&& complainAboutMissingVersionRange(packageRef, ee)) { | |||
&& complainAboutMissingVersionRange(packageRef, ee) && !isUnstable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about passing isUnstable
to the complainAboutMissingVersionRange
method? so this method is the one deciding wether to complain or not. Maybe that would be the better place, as it also considers JDK-packages - JDK packages do not have a version which is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to expose a different explanation for unstable APIs being referenced and for non-versioned or unknown dependencies being referenced.
Why is it not complying with with semantic versioning. |
This does not change export versions. It will merely no longer generate import version ranges for unstable API. A version range
I am really keen to know how that works for you as baselining checks against 0.x packages will never emit violations… |
I don't think that there is any mean for "unstable API" in the OSGi specification. Exported packages per se has to comply with the OSGi semantic versioning rules, so there is no exception where it is "allowed" to break it. If you want something like make your consumers aware that you do not plan to follow these rules, I would recommend to use @API Guardian (what is supported by bnd already if I remember correctly). So I think the assumption
is simply wrong and does not match the OSGi specification and what bnd does here is generally valid. The main problem with an export without a version actually is that one can not define a lower bound but this does not mean an upper bound is of no use! Eclipse makes some use of this by do not version the API of packages but only on the bundle level in wich case one then need to require the bundle with a suitable range (what is a much stronger requirement). |
I digged a bit in git to find out where the bnd treatment of |
If you are really concerned for this I think the solution is not to use no version range but instead bnd must generate a provider range that would be |
This closes #6701