${range} macro not expanded for self-imported package

Hi,

I am using Bndtools 6.3.1, and I am trying to generate OSGi metadata for two third-party jars. Specifically:

org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10
org.jetbrains.kotlin:kotlin-sldlib-jdk8:1.7.10

to accompany the org.jetbrains.kotlin:kotlin-osgi-bundle:1.7.10 which JetBrains provides.

I have tried to apply a ${range} macro to my kotlin.* package import for kotlin-stdlib-jdk8, like this:

Import-Package: \
    kotlin.*;version='\${range;[===,==+);\${@}}',\
    android.os.*:o;resolution:=optional,\
    *

but Bnd is generating this:

Import-Package:
    kotlin;version="[1.7.10,1.7.11)", \
    kotlin.collections;version="[1.7.10,1.7.11)", \
    kotlin.internal.jdk7;version="[1.7.10,1.7.11)", \
    kotlin.jvm.functions;version="[1.7.10,1.7.11)", \
    kotlin.jvm.internal;version="[1.7.10,1.7.11)", \
    kotlin.random;version="[1.7.10,1.7.11)", \
    kotlin.random.jdk8;version="${range;[===,==+);${@}}", \
    kotlin.ranges;version="[1.7.10,1.7.11)", \
    kotlin.sequences;version="[1.7.10,1.7.11)", \
    kotlin.text;version="[1.7.10,1.7.11)", \
    kotlin.time;version="[1.7.10,1.7.11)", \
    android.os;resolution:=optional

which is correct except for the kotlin.random.jdk8 package.

Without the ${range} macro, Bnd only generates kotlin.random.jdk8 (i.e. without a version) for this package.

Have I made a syntax error in my macro please? Although it seems unlikely, considering how all the other package versions are correct :exploding_head:.

Thanks for any help here,
Cheers,
Chris

I have found this earlier issue which looks very much like mine. Following its advice, I have changed my Import-Package to:

Import-Package: \
    kotlin.*jdk8:o;provide:=true,\
    kotlin.jvm.optionals.*:o;provide:=true,\
    kotlin.*;version='${range;[===,==+);${@}}',\
    android.os.*:o;resolution:=optional,\
    *

which seems to do the trick…

Cheers,
Chris

Silly question @chrisr3 but is that :o; a formatting anomaly?

No, it’s recently-added “Bnd-Fu” that declares this package instruction as “optional”. Basically, it means Bnd won’t complain if the wildcard doesn’t match anything.