bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
532 stars 305 forks source link

Remove imports of exports without a version range #6270

Closed chrisrueger closed 2 months ago

chrisrueger commented 2 months ago

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 https://github.com/bndtools/bnd/issues/6267#issuecomment-2351036049 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

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
pkriens commented 2 months ago

LGTM

chrisrueger commented 2 months ago

Thanks @pkriens , I will merge then.