# How to generate a source bundle with the BND Maven plugin

**URL:** <https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281>\
**Category:** GENERAL\
**Created:** [December 22, 2022, 10:37am UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281 "2022-12-22T10:37:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rec](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rec/32/155_2.png) [@rec](https://bnd.discourse.group/u/rec)\
**Post date:** [December 22, 2022, 10:37am UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/1 "2022-12-22T10:37:32Z")

</div>

When trying to debug under OSGI in Eclipse using the bnd Eclipse plugins, I have the problem that sources are not obtained through either the Eclipse workspace or through Maven source JARs related to the bundles that I am trying to debug. Instead, I get a message like **error downloading source: bundle x.y.z.source:1.2.3 does not exist in this workspace**. I assume “workspace” here refers to the BND workspace and not to the Eclipse workspace. And I did not find any information on how to generate these “…source” bundles. Any pointers?

As a workaround, I currently have to have projects with the relevant source open in the Eclipse workspace and manually add them to the source lookup in every debug run.

---

<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:** [December 22, 2022, 1:54pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/2 "2022-12-22T13:54:02Z")

</div>

Which Bnd Eclipse plugins are you referring two? the Bnd Workspace or Bnd M2e?

---

<div class="post-metadata">

**Author:** ![rec](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rec/32/155_2.png) [@rec](https://bnd.discourse.group/u/rec)\
**Post date:** [December 22, 2022, 2:07pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/3 "2022-12-22T14:07:21Z")

</div>

@rotty3000 I don’t know? 🙂

I guess the Eclipse plugins… which ones would these be?

 ![Screenshot 2022-12-22 at 15.06.57](https://global.discourse-cdn.com/free1/uploads/bnd/original/1X/8773d50ef134da56569a1c9e5eb792af9f823053.png)

---

<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:** [December 22, 2022, 2:37pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/4 "2022-12-22T14:37:16Z")

</div>

What build tool do you use to build your projects from the command line; maven, gradle (bnd standalone gradle plugins) or bnd’s proprietary workspace (+ gradle)?

---

<div class="post-metadata">

**Author:** ![rec](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rec/32/155_2.png) [@rec](https://bnd.discourse.group/u/rec)\
**Post date:** [December 22, 2022, 3:09pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/5 "2022-12-22T15:09:53Z")

</div>

For some bundles, I use the maven-bnd-plugin and for others I use the maven-bundle-plugin. It doesn’t seem to matter though, as in Eclipse, the sources of neither of these can be resolved.

But anyway, since I’m working in Eclipse and I have the projects even open in Eclipse, most of the projects get resolved from the Eclipse workspace - and I would expected their sources to be resolved from there as well.

---

<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:** [December 22, 2022, 3:37pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/6 "2022-12-22T15:37:59Z")

</div>

I’ve never experienced M2e not resolving resources for maven projects regardless of which packaging plugin was being used. That should actually fall on M2e’s integration with (I believe) the maven resource plugin. Perhaps if you shared a reproducer project we might be able to spot something out of place?

---

<div class="post-metadata">

**Author:** ![rec](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rec/32/155_2.png) [@rec](https://bnd.discourse.group/u/rec)\
**Post date:** [December 22, 2022, 3:40pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/7 "2022-12-22T15:40:44Z")

</div>

Puh, I might try next year - can’t promise it though. I’m sure I’ll hit the issue again… if I have more info, I’ll definitely post it.

---

<div class="post-metadata">

**Author:** ![rec](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rec/32/155_2.png) [@rec](https://bnd.discourse.group/u/rec)\
**Post date:** [December 22, 2022, 4:02pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/8 "2022-12-22T16:02:52Z")

</div>

Btw. this is what I get when I press “Edit lookup path” after trying to open a file in the debugger that has no source attachment. As you can see, for most of the bundles (and this even includes bundles obtained from Maven Central) no sources can be found. Oddly, for some like assertj, they can be found. Source resolving for the same JARs works flawlessly when running my code just as plain Java without OSGI e.g. as plain JUnit tests (i.e. without runbnd).

 ![Screenshot 2022-12-22 at 16.59.41](https://global.discourse-cdn.com/free1/uploads/bnd/original/1X/6aa914294c831d53fb53aef3d52c1d4690afde57.png)

---

<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:** [December 22, 2022, 5:08pm UTC](https://bnd.discourse.group/t/how-to-generate-a-source-bundle-with-the-bnd-maven-plugin/281/9 "2022-12-22T17:08:49Z")

</div>

To be honest I haven’t tried this recently in I know there were some Bnd/M2e issues due to M2e API changes that bnd only recently addressed. I wonder if this is a regression. All I can suggest is that you update Eclipse, update M2E, and update bnd m2e integration all to their latest and see what happens (if that’s not already the state you’re in).
