[SOLVED] Pin a dependency version in feature.xml

Trying to integrate a newer Version of ical4j i’m failing to get my bundle built as there is a missing dependency. The resolution of dependencies gives me a wiring error back to (&(osgi.wiring.package=net.fortuna.ical4j.data)(&(version>=3.0.0)(!(version>=4.0.0)))). From my understanding, the package net.fortuna.ical4j.data in 3.0.0 <= version < 4.0.0 is searched, which is not configured in the feature.xml:

<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.icalpresence-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
    <feature name="openhab-binding-icalpresence" description="iCalPresence Binding" version="${project.version}">
        <bundle dependency="true">mvn:org.mnode.ical4j/ical4j/3.0.4</bundle>
        <bundle dependency="true">mvn:org.apache.commons/commons-lang3/3.9</bundle>
        <bundle dependency="true">mvn:javax.cache/cache-api/1.0.0</bundle>
        <bundle dependency="true">mvn:org.apache.commons/commons-collections4/4.1</bundle>
        <bundle dependency="true">mvn:javax.mail/javax.mail-api/1.6.2</bundle>
        <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.icalpresence/${project.version}</bundle>

As the current version of ical4j does not export the dependencies properly, i’d like to pin the version until this issue is fixed. Is there a way to specify the exact version?

Which version is defined in the pom?

The same version and also the same versions of the dependencies. See for reference the pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <!-- [...] -->
    <!-- own dependencies -->
    <!-- requirements by ical4j -->
    <!-- CDDL! -->

However there are also newer versions of some dependencies available where ping may be necessary in case of trouble. I’ve also writen a small test for the logic, there (in my understanding) the dependencies defined in the pom should be used.

I assume from that behavior i should use always same versions in feature.xml and pom.xml. Is this assumption wrong?

Are you sure that one of the bundles really exports that package? I think that is the problem, because 3.0.4 is in the range mentioned above. Maybe you need to add another bundle to the feature.

hmm. I also thought about that problem. Looking into the META-INF/MANIFEST.MF inside ical4j.jar, i would say yes it does:

Manifest-Version: 1.0
Export-Package: net.fortuna.ical4j.agent;version="3.0.4";uses:="net.fo
 el.component,net.fortuna.ical4j.validate", [...]
Bundle-SymbolicName: org.mnode.ical4j
Bundle-Version: 3.0.4
Bundle-Name: ical4j
Bundle-ManifestVersion: 2
Bnd-LastModified: 1544925820000
Import-Package: [...]
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Created-By: 1.8.0_151 (Oracle Corporation)
Tool: Bnd-

In this case i wanted to pin this library as the following version had problems with the exported list. However the author Ben Fortuna has fixed it already/will fix it at next release (a Big Thank You, Mr. Fortuna!). But the library is still using specific versions of other libraries.

I have also looked up all the dependencies - but have nothing found required further. Do have another ideas how to solve?

The solution for this is in following topic:

Dependencies should now be included in a different scope. This also enables the possibility to pin a dependency. Dependencies which are likely to be used by other addons also shouldn’t be embedded - so they can be shared.

1 Like