# @org.osgi.annotation.bundle.Export with -includeresource

**URL:** <https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76>\
**Category:** GENERAL\
**Created:** [January 19, 2021, 12:08pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76 "2021-01-19T12:08:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![juergen-albert](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/juergen-albert/32/20_2.png) [@juergen-albert](https://bnd.discourse.group/u/juergen-albert)\
**Post date:** [January 19, 2021, 12:08pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/1 "2021-01-19T12:08:53Z")

</div>

Not sure if this is a Bug of a Feature:

The Moment I define a `-includeresource` instruction, we don’t look for `@Export` anymore and every package becomes excluded. I do understand that we ignore them, as soon as I manually define Import or Export packages, but an the `-includeresource` instruction should not deactivate this feature.

Do I misunderstand something here?

---

<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:** [January 19, 2021, 12:50pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/2 "2021-01-19T12:50:58Z")

</div>

There should be no relationship. But it you specify -includeresource, then Bnd will not automatically -includepackage all of the packages in the output folder, so there may be no package in the bundle which may have Export annotations.

---

<div class="post-metadata">

**Author:** ![juergen-albert](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/juergen-albert/32/20_2.png) [@juergen-albert](https://bnd.discourse.group/u/juergen-albert)\
**Post date:** [January 19, 2021, 1:07pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/3 "2021-01-19T13:07:18Z")

</div>

Now I’m more confused then before. Should there be a relationship between `-includeresource` and the interpretation of Export Annotations or not? If I read your statement correctly, then `-includeresource` will deactivate the interpretation of Bundle Annotations.

If so, I think this is highly misleading. In my understanding `-includeresource` should be used to add things like e.g. property files or other static content. I don’t see a reason, why this would block me from using the Bundle annotations.

Do we have an instruction to tell bnd to look for annotations anyway?

---

<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:** [January 19, 2021, 1:39pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/4 "2021-01-19T13:39:01Z")

</div>

As I said, there is no relationship. Bnd will process all packages (which are not -privatepackage or Private-Package) in the bundle for Export annotations.

My point is about what packages are actually in the bundle. By default, Bnd will include all the packages in the project which are compiled into the bin folder. But if your Bnd instructions use -includeresource, or -includepackage, or Export-Package, then Bnd assumes you are in full control of what goes in the bundle and Bnd will not automatically include all the packages from the bin folder. See [https://github.com/bndtools/bnd/blob/a211ec952529d2cf70ef7155f379064cd5c0457f/biz.aQute.bndlib/src/aQute/bnd/build/ProjectBuilder.java#L768-L800](https://github.com/bndtools/bnd/blob/a211ec952529d2cf70ef7155f379064cd5c0457f/biz.aQute.bndlib/src/aQute/bnd/build/ProjectBuilder.java#L768-L800)

---

<div class="post-metadata">

**Author:** ![juergen-albert](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/juergen-albert/32/20_2.png) [@juergen-albert](https://bnd.discourse.group/u/juergen-albert)\
**Post date:** [January 19, 2021, 2:07pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/5 "2021-01-19T14:07:51Z")

</div>

It might be already to late to change this, but making `-includeresource` part of this assumption is a bit much for my taste.

Can we change this or alternatively introduce an instruction to do process them anyway?

---

<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:** [January 19, 2021, 2:15pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/6 "2021-01-19T14:15:32Z")

</div>

This behavior has been in place since Bnd 3.2.0. So I think it is a bit late to reverse course now. The principle is either you fully control the bundle content, or Bnd defaults to the content of the output folder. Some blending of the two can be confusing.

---

<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:** [January 19, 2021, 5:03pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/7 "2021-01-19T17:03:13Z")

</div>

I agree with Jürgen that we messed up with this. For my customers I always set the following in the `build.bnd` nowadays to prevent this problem:

```auto
-includepackage.x *;from:=classes # classes= the src output directory
-includeresource.x -src/main/resources/

```

This creates the expected behavior but does not throw its hands in the air when there is even the tiniest hint the user like to say something about the content.

I recall I wrote something about this a few months ago. One note, I created a recent fix when there are no packages in the source directory, this created an incorrect error.

---

<div class="post-metadata">

**Author:** ![juergen-albert](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/juergen-albert/32/20_2.png) [@juergen-albert](https://bnd.discourse.group/u/juergen-albert)\
**Post date:** [January 19, 2021, 9:25pm UTC](https://bnd.discourse.group/t/org-osgi-annotation-bundle-export-with-includeresource/76/8 "2021-01-19T21:25:35Z")

</div>

Works like charm! Thanks heaps.
