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

**URL:** <https://bnd.discourse.group/t/range-macro-not-expanded-for-self-imported-package/261>\
**Category:** GENERAL\
**Created:** [September 18, 2022, 7:13pm UTC](https://bnd.discourse.group/t/range-macro-not-expanded-for-self-imported-package/261 "2022-09-18T19:13:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisr3](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisr3/32/58_2.png) [@chrisr3](https://bnd.discourse.group/u/chrisr3)\
**Post date:** [September 18, 2022, 7:13pm UTC](https://bnd.discourse.group/t/range-macro-not-expanded-for-self-imported-package/261/1 "2022-09-18T19:13:45Z")

</div>

Hi,

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

```nohighlight
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:

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

```

but Bnd is generating this:

```nohighlight
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 🤯.

Thanks for any help here,  
Cheers,  
Chris

```auto

```

---

<div class="post-metadata">

**Author:** ![chrisr3](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisr3/32/58_2.png) [@chrisr3](https://bnd.discourse.group/u/chrisr3)\
**Post date:** [September 18, 2022, 8:30pm UTC](https://bnd.discourse.group/t/range-macro-not-expanded-for-self-imported-package/261/2 "2022-09-18T20:30:17Z")

</div>

I have found [this earlier issue](https://github.com/bndtools/bnd/issues/1368) which looks very much like mine. Following its advice, I have changed my `Import-Package` to:

```nohighlight
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

---

<div class="post-metadata">

**Author:** ![rotty3000](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rotty3000/32/16_2.png) [@rotty3000](https://bnd.discourse.group/u/rotty3000)\
**Post date:** [September 19, 2022, 1:09pm UTC](https://bnd.discourse.group/t/range-macro-not-expanded-for-self-imported-package/261/3 "2022-09-19T13:09:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chrisr3](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisr3/32/58_2.png) [@chrisr3](https://bnd.discourse.group/u/chrisr3)\
**Post date:** [September 19, 2022, 7:18pm UTC](https://bnd.discourse.group/t/range-macro-not-expanded-for-self-imported-package/261/4 "2022-09-19T19:18:55Z")

</div>

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.
