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

Resolution fails with repositories loaded from XML Repository Format #6284

Closed mnlipp closed 1 month ago

mnlipp commented 2 months ago

Problem:

Resolution of my project works when I use a repository which is initialized using downloaded jars. The resolution fails when I serialize this repository using the XML Repository Format and then use a new repository initialized by deserializing the XML.

Steps to reproduce:

1 Initialize a repository (aQute.bnd.osgi.repository.ResourcesRepository to be specific) from jars, using ResourceBuilder.addFile and then ResourceRepository.add 2 Try resolution of some sample project, works as expected 3 Serialize respository to XML 4 Initialize a repository from the serialized XML 5 Try resolution of sample project using the latter repository, fails unexpectedly.

The reported problem is (only the first is shown): grafik

Expected behavior:

Serializing/deserializing should not have an impact on successful resolution.

Note: I thought that I had identified the root cause with #6211. But according to the comment, the information that my workaround restores should not be (or does not need to be) restored. So there must be some other cause for the failing resolution.

One possible cause (just guessing) could be that the requirement in namespace bnd.multirelease should not be there in the first place. Here's the resource definition created by bnd for jackson-core, you can find the requirement at the bottom:

  <resource>
    <capability namespace="osgi.identity">
      <attribute name="license" value="https://www.apache.org/licenses/LICENSE-2.0.txt"/>
      <attribute name="osgi.identity" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="documentation" value="https://github.com/FasterXML/jackson-core"/>
      <attribute name="description" value="Core Jackson processing abstractions (aka Streaming API), implementation for JSON"/>
      <attribute name="type" value="osgi.bundle"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core.async,com.fasterxml.jackson.core.exc,com.fasterxml.jackson.core.format,com.fasterxml.jackson.core.io,com.fasterxml.jackson.core.json,com.fasterxml.jackson.core.sym,com.fasterxml.jackson.core.type,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="1114690390,2102359062,748621597,1895597947,2879770,1204336351,2071943320,354249820,657418875,685445846,-710234398,-1990478247,1209236463,1978794667,847240413,-293016060,1601302083,1253012045,-1952931001,801374503,1839904342,1721768912,-18957291,738820180,765053415,910937553,-762337588,-222858959,364663799,-25799004,-981244400,802621198,323683072,547605696,1052448407,-521608041,-1029172777,316139508,1293416465,2009947896,1450638048,2016261304,596865879,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.async"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="-2140142532,-1964375949,616297427,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.exc,com.fasterxml.jackson.core.io,com.fasterxml.jackson.core.json,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.base"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="-1449548764,1028877232,734626387,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.exc"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="-609351417,-940816775,-129771623,709571312,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.filter"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="-1539080882,1946569390,1914811830,507500796,-206636367,-2130470466" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.format"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="175461191,-434218607,83459,-834831343,1110255878,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.io"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="1777390032,-854042115,-1317467575,-738157917,1391231177,350971634,-341865251,-235909719,-1761873999,-1635930149,2121036707,-1192861204,-1909728799,1106303434,-1159559142,-1103551498,-840641835,-1153656183,1471399780" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.io.schubfach"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="1661436773,1142824314,-1550426519" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.base,com.fasterxml.jackson.core.format,com.fasterxml.jackson.core.io,com.fasterxml.jackson.core.sym,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.json"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="-693759366,1385577157,1387105131,-57204040,-1723764463,640464472,-514779656,1849449279,-710995502,181953495,-1829473738,1018736314,757431416,1076197323,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.async,com.fasterxml.jackson.core.exc,com.fasterxml.jackson.core.io,com.fasterxml.jackson.core.json,com.fasterxml.jackson.core.sym"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.json.async"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="813408721,-440496439,-1292403398,-672612853,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.exc,com.fasterxml.jackson.core.util"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.sym"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="15113596,-2098737362,2000631306,-1957402737,2420395,75032294,75032295,75032296,75032323,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.type"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="585914226,-1421180655,507500796,843417045,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.package">
      <directive name="uses" value="com.fasterxml.jackson.core,com.fasterxml.jackson.core.async,com.fasterxml.jackson.core.exc,com.fasterxml.jackson.core.io"/>
      <attribute name="bundle-symbolic-name" value="com.fasterxml.jackson.core.jackson-core"/>
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.util"/>
      <attribute name="version" value="2.18.0.rc1" type="Version"/>
      <attribute name="bnd.hashes" value="2060138072,-584620865,-943377516,-712958902,1113301914,1592799883,176875129,838990376,-454842845,-2034101035,-440939664,-1320044989,-739622113,1898587600,724986192,1508945388,2039171112,281410617,155585221,-250663149,-712902369,-2072366307,-222976336,-231675197,-66368339,145404586,-1909941450,2433570,1762322564,-474887024,-80634723,-2015307890,-876196318,-237237989,650126367,-347505629,-123382194,-935769107,2129459768,-1239088788,-1937965862,-1923478059" type="List&lt;Long&gt;"/>
    </capability>
    <capability namespace="osgi.wiring.bundle">
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.bundle" value="com.fasterxml.jackson.core.jackson-core"/>
    </capability>
    <capability namespace="osgi.wiring.host">
      <attribute name="bundle-version" value="2.18.0.rc1" type="Version"/>
      <attribute name="osgi.wiring.host" value="com.fasterxml.jackson.core.jackson-core"/>
    </capability>
    <capability namespace="osgi.content">
      <attribute name="size" value="596287" type="Long"/>
      <attribute name="mime" value="application/vnd.osgi.bundle"/>
      <attribute name="url" value="jackson-core-2.18.0-rc1.jar"/>
      <attribute name="osgi.content" value="7C603C1343396AB3BB95F209782DE275CCA30E7FE8A72E02C93BA03A2CD89551"/>
    </capability>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.async)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.async"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.base)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.base"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.exc)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.exc"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.format)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.format"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.io)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.io"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.io.schubfach)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.io.schubfach"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.json)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.json"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.json.async)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.json.async"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.sym)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.sym"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.type)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.type"/>
    </requirement>
    <requirement namespace="osgi.wiring.package">
      <directive name="filter" value="(&amp;(osgi.wiring.package=com.fasterxml.jackson.core.util)(version&gt;=2.18.0)(!(version&gt;=3.0.0)))"/>
      <attribute name="osgi.wiring.package" value="com.fasterxml.jackson.core.util"/>
    </requirement>
    <requirement namespace="bnd.multirelease">
      <directive name="filter" value="(&amp;(bnd.multirelease=com.fasterxml.jackson.core.jackson-core)(&amp;(version&gt;=2.18.0.rc1)(version&lt;=2.18.0.rc1)))"/>
    </requirement>
  </resource>

The requirement does not cause problems when the repository is initialized from jars, because this creates the bnd.multirelease capabilities. However, these capabilities are not restored when deserializing the repository XML (unless I use my workaround).

pkriens commented 1 month ago

Can you add a full (but please a minimal as possible) repo that fails?

The supporting resources should be in the XML?

mnlipp commented 1 month ago

See https://github.com/bndtools/bnd/issues/6211#issuecomment-2371804262