Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-549

Import-Package should not include "snapshot" from snapshot dependencies

    Details

      Description

      I have a jar named:

      struts2-core-2.1.3-SNAPSHOT

      and a bundle that depends on it (imported with "compile" scope). The pom section in the bundle is:

      <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <extensions>true</extensions>
      <version>1.4.0</version>
      <configuration>
      <instructions>
      <manifestLocation>META-INF</manifestLocation>
      <Export-Package>
      org.apache.struts2.osgi.admin*
      </Export-Package>
      <Import-Package>*,com.opensymphony.xwork2</Import-Package>
      <Bundle-Activator>
      org.apache.struts2.osgi.admin.MyBundleActivator
      </Bundle-Activator>
      </instructions>
      </configuration>
      </plugin>

      The generated Import-Package is:

      Import-Package: org.apache.struts2.dispatcher; version="2.1.3.SNAPSHOT"

      Which prevents the package from being resolved. (I tried exporting it as "2.1" and "2.1.3.SNAPSHOT"). The default Maven2OsgiConverter just converts "-" to "." and leaves "SNAPSHOT" in place.

        Activity

        Hide
        mcculls Stuart McCulloch added a comment -

        Quick update - I haven't had time to progress these issues because I've been working at a customer site - but I hope to devote some cycles when I'm back in Malaysia next week. If any of these need fixing urgently feel free to keep bugging me until they're fixed

        Show
        mcculls Stuart McCulloch added a comment - Quick update - I haven't had time to progress these issues because I've been working at a customer site - but I hope to devote some cycles when I'm back in Malaysia next week. If any of these need fixing urgently feel free to keep bugging me until they're fixed
        Hide
        mcculls Stuart McCulloch added a comment -

        The import version actually comes straight from Bnd when it generates the manifest, not the Maven2OsgiConverter - the next update of Bnd is planned to be integrated with bundleplugin 1.4.3, so setting the fix target to that version.

        Show
        mcculls Stuart McCulloch added a comment - The import version actually comes straight from Bnd when it generates the manifest, not the Maven2OsgiConverter - the next update of Bnd is planned to be integrated with bundleplugin 1.4.3, so setting the fix target to that version.
        Hide
        pkriens Peter Kriens added a comment -

        I need more information ... Where is the 2.1.3.SNAPSHOT picked up from? The manifest or from a packaginfo?

        The problem is that as far as I can see the exporter explicitly says this version string. How do I know this is not intended?

        Peter Kriens

        Show
        pkriens Peter Kriens added a comment - I need more information ... Where is the 2.1.3.SNAPSHOT picked up from? The manifest or from a packaginfo? The problem is that as far as I can see the exporter explicitly says this version string. How do I know this is not intended? Peter Kriens
        Hide
        sahoo Sahoo added a comment -

        Has a decision been made about this bug? I am seeing a slightly different issue while using maven-bundle-plugin's manifest goal. My project A1depends on an OSGi artifact called A2. A2 exports a package p with version 0.3.19-SNAPSHOT. In the Import-Package of A1, I see the version as 0.3 only! I am using v1.4.3 of the plugin.

        Show
        sahoo Sahoo added a comment - Has a decision been made about this bug? I am seeing a slightly different issue while using maven-bundle-plugin's manifest goal. My project A1depends on an OSGi artifact called A2. A2 exports a package p with version 0.3.19-SNAPSHOT. In the Import-Package of A1, I see the version as 0.3 only! I am using v1.4.3 of the plugin.
        Hide
        mcculls Stuart McCulloch added a comment -

        Hi Sahoo,

        Could be similar - if you have a concrete testcase please attach it to the issue, so Peter has something to work from.
        FYI, the update of BND was postponed to the 1.6.0 release of the bundleplugin so 1.4.3 is still using the old version.

        Cheers, Stuart

        Show
        mcculls Stuart McCulloch added a comment - Hi Sahoo, Could be similar - if you have a concrete testcase please attach it to the issue, so Peter has something to work from. FYI, the update of BND was postponed to the 1.6.0 release of the bundleplugin so 1.4.3 is still using the old version. Cheers, Stuart
        Hide
        sahoo Sahoo added a comment -

        Stuart,

        It was my mistake. In my test case (refer to my previous comment), A2 exports p with version 0.3.18 instead of 0.3.19-SNAPSHOT. In A1, I see the Import-Package as 0.3 only. BND document as shown below suggests that it should be 0.3.18:
        "During processing, bnd will attempt to find the exported version of imported packages. If no version or version range is specified on the import instruction, the exported version will then be used though the micro part and the qualifier are dropped. That is, when the exporter is 1.2.3.build123, then the import version will be 1.2.3."

        I am attaching a simple test case (Felix-549.zip). In the test case. The relevant portion of generated manifest for both the artifacts are given below:

        A2/target/classes/META-INF/MANIFEST.MF
        ----------------------------------------------------------
        Import-Package: p;version="0.3.18"
        Export-Package: p;version="0.3.18"

        A1/target/classes/META-INF/MANIFEST.MF
        -----------------------------------------------------------
        Import-Package: org.osgi.framework;version="1.3",p;version="0.3"

        So, I still think it is a bug.

        Thanks,
        Sahoo

        Show
        sahoo Sahoo added a comment - Stuart, It was my mistake. In my test case (refer to my previous comment), A2 exports p with version 0.3.18 instead of 0.3.19-SNAPSHOT. In A1, I see the Import-Package as 0.3 only. BND document as shown below suggests that it should be 0.3.18: "During processing, bnd will attempt to find the exported version of imported packages. If no version or version range is specified on the import instruction, the exported version will then be used though the micro part and the qualifier are dropped. That is, when the exporter is 1.2.3.build123, then the import version will be 1.2.3." I am attaching a simple test case (Felix-549.zip). In the test case. The relevant portion of generated manifest for both the artifacts are given below: A2/target/classes/META-INF/MANIFEST.MF ---------------------------------------------------------- Import-Package: p;version="0.3.18" Export-Package: p;version="0.3.18" A1/target/classes/META-INF/MANIFEST.MF ----------------------------------------------------------- Import-Package: org.osgi.framework;version="1.3",p;version="0.3" So, I still think it is a bug. Thanks, Sahoo
        Hide
        sahoo Sahoo added a comment -

        Test case that shows that Import-Package uses upto minor component of the version string.

        Show
        sahoo Sahoo added a comment - Test case that shows that Import-Package uses upto minor component of the version string.
        Hide
        mcculls Stuart McCulloch added a comment -

        I ran the testcase against trunk and both manifests now see the same import version ("0.3") which is major.minor, as per the latest Bnd documentation at http://aqute.biz/Code/Bnd - note that Peter has also added a new setting called -versionpolicy (see http://aqute.biz/Code/Bnd#versionpolicy) to give more control over how import versions are derived from the exported version.

        I'll deploy a new 1.5.0-SNAPSHOT tomorrow morning (8hrs from now).

        Show
        mcculls Stuart McCulloch added a comment - I ran the testcase against trunk and both manifests now see the same import version ("0.3") which is major.minor, as per the latest Bnd documentation at http://aqute.biz/Code/Bnd - note that Peter has also added a new setting called -versionpolicy (see http://aqute.biz/Code/Bnd#versionpolicy ) to give more control over how import versions are derived from the exported version. I'll deploy a new 1.5.0-SNAPSHOT tomorrow morning (8hrs from now).
        Hide
        mcculls Stuart McCulloch added a comment -

        Closing as maven-bundle-plugin 2.0.0 has been released.

        Show
        mcculls Stuart McCulloch added a comment - Closing as maven-bundle-plugin 2.0.0 has been released.

          People

          • Assignee:
            mcculls Stuart McCulloch
            Reporter:
            musachy musachy
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development