# Can I add instructions via properties/macros?

**URL:** <https://bnd.discourse.group/t/can-i-add-instructions-via-properties-macros/265>\
**Category:** GENERAL\
**Created:** [September 29, 2022, 3:20pm UTC](https://bnd.discourse.group/t/can-i-add-instructions-via-properties-macros/265 "2022-09-29T15:20:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ind1go](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/ind1go/32/147_2.png) [@ind1go](https://bnd.discourse.group/u/ind1go)\
**Post date:** [September 29, 2022, 3:20pm UTC](https://bnd.discourse.group/t/can-i-add-instructions-via-properties-macros/265/1 "2022-09-29T15:20:37Z")

</div>

Hi all! I’ve got a Gradle non-workspace bnd build, with a `bnd.bnd` file. I have a set of libraries that the Gradle build is aware of (via Gradle dependencies), that I want to add to the `Bundle-ClassPath`, so I intend to use `-includeresource` statements.

Because the set of dependencies is dynamic, I don’t want to add it to the `bnd.bnd`. My naïve attempt was to set up a property in the `build.gradle`:

```auto
jar {
    bundle {
        properties = [
            "extraincluderesources": "-includeresource.extra=lib/<name>.jar=<name>-*.jar;lib:=true"
        ]
    }
}

```

and then simply reference that property in a line of its own, in the `bnd.bnd`:

```auto
${extraincluderesources}

```

This doesn’t work, with the following warning:

```auto
warning: No value specified for key: ${extraincluderesources}. An empty value should be specified as '${extraincluderesources}:' or '${extraincluderesources}=': <<${extraincluderesources}

```

Obviously I’m being foolish, but what is the right way to dynamically include a list of dependencies?

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [September 29, 2022, 3:44pm UTC](https://bnd.discourse.group/t/can-i-add-instructions-via-properties-macros/265/2 "2022-09-29T15:44:44Z")

</div>

I would try:

```auto
jar {
    bundle {
        properties = [
            "extraincluderesources": "lib/<name>.jar=<name>-*.jar;lib:=true"
        ]
    }
}

```

Then in the bnd file

```auto
-includeresource.extra=${extraincluderesources}

```

Bnd will expand macros in the value of a property but not the key.

---

<div class="post-metadata">

**Author:** ![ind1go](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/ind1go/32/147_2.png) [@ind1go](https://bnd.discourse.group/u/ind1go)\
**Post date:** [September 29, 2022, 3:54pm UTC](https://bnd.discourse.group/t/can-i-add-instructions-via-properties-macros/265/3 "2022-09-29T15:54:04Z")

</div>

Thanks @bjhargrave, that’s done the trick.

If I extend that beyond what I need at the moment, I think that means I shouldn’t aim for being able to dynamically generate arbitrary `-includeresource.extra1=`, `-includeresource.extra2=`, `-includeresource.extra3=`, … statements - instead, leave a single placeholder and do the hard work of constructing a single value on the Gradle side.

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [September 29, 2022, 6:23pm UTC](https://bnd.discourse.group/t/can-i-add-instructions-via-properties-macros/265/4 "2022-09-29T18:23:52Z")

</div>

> [@ind1go](#):
>
> leave a single placeholder and do the hard work of constructing a single value on the Gradle side.

Yes. Since it is a gradle-side issue to determine the set of libraries. No need to clutter the bnd-side.
