Skip to content
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

Remove imports of exports without a version range #6270

Conversation

chrisrueger
Copy link
Contributor

@chrisrueger chrisrueger commented Sep 14, 2024

Closes #6267

imports (coming from exports) should not be added if the export does not specify a version, because it would lead to imports without a version-range. this could cause resolver problems because the resolver then has no version constrains and too many wiring options.

Testcases

The existing testcase BuilderTest#testNoImportForUsedExport_971 needed adjustment.
According to #6267 (comment) it does also not comply with the spec in its previous form.

Importing an exported package must use a version range according to its compatibility requirements, being either a consumer or a provider of that API

Here is what has changed:

BEFORE this PR

testNoImportForUsedExport_971

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Created-By: 21.0.3 (Eclipse Adoptium)
Tool: Bnd-7.1.0
Bnd-LastModified: 1726266483369
Export-Package: test.missingimports_971.p1;version="0.0.0",test.missingi
 mports_971.p2;version="0.0.0",test.missingimports_971.p4;version="0.0.0
 "
Import-Package: java.lang,test.missingimports_971.p1,test.missingimports
 _971.p2
Private-Package: test.missingimports_971.p3
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))"
Bundle-SymbolicName: biz.aQute.bndlib.tests
Bundle-Name: biz.aQute.bndlib.tests
Bundle-Version: 0

AFTER this PR

testNoImportForUsedExport_971 was adjusted

  • to add version to the exports to make it still pass.
  • because if versions are on the exports directly (not derived from the bundle version) then those versions are added to the imports as a range and the test passes as before.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Created-By: 21.0.3 (Eclipse Adoptium)
Tool: Bnd-7.1.0
Bnd-LastModified: 1726339024661
Export-Package: test.missingimports_971.p1;version="1.1.0",test.missingi
 mports_971.p2;version="1.1.0",test.missingimports_971.p4;version="1.1.0
 "
Import-Package: java.lang,test.missingimports_971.p1;version="[1.1,2)",t
 est.missingimports_971.p2;version="[1.1,2)"
Private-Package: test.missingimports_971.p3
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))"
Bundle-SymbolicName: biz.aQute.bndlib.tests
Bundle-Name: biz.aQute.bndlib.tests
Bundle-Version: 0

Additionally I have added another test which basically is like testNoImportForUsedExport_971 before this PR, but this testcase now shows that the imports are not added when the exports don't have a version.

testEnsureNoImportForUsedExport_971_WithMissingExportVersion

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Created-By: 21.0.3 (Eclipse Adoptium)
Tool: Bnd-7.1.0
Bnd-LastModified: 1726339053858
Export-Package: test.missingimports_971.p1;version="0.0.0",test.missingi
 mports_971.p2;version="0.0.0",test.missingimports_971.p4;version="0.0.0
 "
Import-Package: java.lang
Private-Package: test.missingimports_971.p3
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=17))"
Bundle-SymbolicName: biz.aQute.bndlib.tests
Bundle-Name: biz.aQute.bndlib.tests
Bundle-Version: 0

imports (coming from exports) should not be added if the export does not specify a version, because it would lead to imports without a version. this could cause resolver problems because the resolver then has no version constrains and too many wiring options.

Signed-off-by: Christoph Rueger <[email protected]>
@chrisrueger chrisrueger force-pushed the 6267-Prevent-generation-of-Substitution-Packages-(Import-Package)-without-version branch from 39a81de to a95fe11 Compare September 14, 2024 18:44
@chrisrueger chrisrueger marked this pull request as ready for review September 15, 2024 11:23
@pkriens
Copy link
Member

pkriens commented Sep 16, 2024

LGTM

@chrisrueger
Copy link
Contributor Author

Thanks @pkriens , I will merge then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent generation of Substitution Packages (Import-Package) without version
2 participants