# Version attribute of DynamicImport-Package with -includeresource for Import-Package

**URL:** <https://bnd.discourse.group/t/version-attribute-of-dynamicimport-package-with-includeresource-for-import-package/523>\
**Category:** GENERAL\
**Created:** [April 7, 2025, 7:59pm UTC](https://bnd.discourse.group/t/version-attribute-of-dynamicimport-package-with-includeresource-for-import-package/523 "2025-04-07T19:59:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisrueger](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisrueger/32/18_2.png) [@chrisrueger](https://bnd.discourse.group/u/chrisrueger)\
**Post date:** [April 7, 2025, 7:59pm UTC](https://bnd.discourse.group/t/version-attribute-of-dynamicimport-package-with-includeresource-for-import-package/523/1 "2025-04-07T19:59:41Z")

</div>

**Question:**

Should the version attribute of `DynamicImport-Package` in a dependency included via `-includeresource` be considered by bnd for calculating the `Import-Package` header?

**Scenario:**

My Wrapper Bundle **A** :

```auto
-includeresource: \
	${repo;io.micrometer:micrometer-core;latest}; lib:=true,\

Import-Package: *

```

Bnd finds, that this dependecy references `com.github.benmanes.caffeine.cache` in its .class files. And also the dependency specifies a `DynamicImport-Package` for that package **with** a version.

**io.micrometer:micrometer-core:**

```auto
DynamicImport-Package: com.github.benmanes.caffeine.cache;version="2.9.3"

```

which includes a versionrange \>=2.9.3

But my build Wrapper Bundle **A**.jar’s MANIFEST.MF contains :

```auto
Import-Package: com.github.benmanes.caffeine.cache

```

**WITHOUT** a version.

The reason I ask is that I currently get a `pendantic` warning

`Imports that lack version ranges: [com.github.benmanes.caffeine.cache]`

So my question is:  
Is it correct that the Import-Package does not have a version?  
Or could / should bnd theoretically use the information of `DynamicImport-Package` somehow?

Or if not adding the version is ok, could I maybe try to suppress the `pedantic` warning, if that bundle is part of a `DynamicImport-Package`? (i read [here](https://groups.google.com/g/bndtools-users/c/94Wb2uQghf8/m/Ts-z1hUsAwAJ) that for `DynamicImport-Package` the version is not that important)

E.g. there is `Analyzer.getManifestInfoFromClasspath(Jar jar, Packages classpathExports, Contracts contracts)` where I would have access to the `domain.getDynamicImportPackage()`

If this is something bnd could / should handle I could start looking into a PR, but wanted to ask first.

Thoughts? @pkriens @bjhargrave

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [April 8, 2025, 7:31am UTC](https://bnd.discourse.group/t/version-attribute-of-dynamicimport-package-with-includeresource-for-import-package/523/2 "2025-04-08T07:31:21Z")

</div>

DynamicImport-Package is a hack since the package provider is undefined. It is a fall back to the time of long classpaths. It is a last bet best effort. We likely never look in this header to get metadata. I always disliked it.

I don’t think it is worth the effort to learn the version from DynamicImport-Package since it is not well defined anyway. But for this purpose it might be useful so I won’t object.

---

<div class="post-metadata">

**Author:** ![chrisrueger](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisrueger/32/18_2.png) [@chrisrueger](https://bnd.discourse.group/u/chrisrueger)\
**Post date:** [April 8, 2025, 8:32am UTC](https://bnd.discourse.group/t/version-attribute-of-dynamicimport-package-with-includeresource-for-import-package/523/3 "2025-04-08T08:32:54Z")

</div>

> [@pkriens](#):
>
> DynamicImport-Package is a hack

Yeah remembered various comments about it 🙂

> [@pkriens](#):
>
> But for this purpose it might be useful so I won’t object.

Do you mean the purpose of supressing this warning?

What would be normal way to avoid that warning `Imports that lack version ranges: [com.github.benmanes.caffeine.cache]` if it was caused by an `-includeresource` / jar wrapping?

---

<div class="post-metadata">

**Author:** ![chrisrueger](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/chrisrueger/32/18_2.png) [@chrisrueger](https://bnd.discourse.group/u/chrisrueger)\
**Post date:** [April 8, 2025, 1:24pm UTC](https://bnd.discourse.group/t/version-attribute-of-dynamicimport-package-with-includeresource-for-import-package/523/4 "2025-04-08T13:24:37Z")

</div>

On that note:

Just found a very useful post in the old forum by @rotty3000 :

> **[Wrapping/repackaging dependencies in bnd-maven-plugin](https://groups.google.com/g/bndtools-users/c/NAdU0_X8OKY/m/iyX-9R0qEAAJ)**

As requested [here](https://github.com/bndtools/bnd/issues/3704#issuecomment-664370808) I will try to also add that to the manual somewhere. Suggestions welcome.
