Bndtools - workflow question: How to setup workspace and 3rd party bundle from different git repo

My scenario:

  1. I have my normal bnd workspace for App A
  2. I have Bundle B from an external git repo of a 3rd party dependency for which I want to do some bugfix. This project has a bnd.bnd file too.

In order to start that external project using the sources I manually copied the repo-folder of Bundle B to my workspace folder, because bnd requires all bundles to be within the workspace.

Great, now I can start this bundle as part of my app (adjusting .bndrun) and start debugging and bugfixing and seeing the fix working right away.

Problem:
This works nice, for development in Eclipse, because I have sources of both projects in my workspace. Debug, Fix, Verify is very fast.

But then I need to remove it from my workspace again, because the sources of Bundle B are not part of my App A.

Question:
How are others solving such a scenario?
How can I develop like this one Bundle B as if it was in the workspace, but is actually not? What would be a typical workflow?

I would not copy the files into your workspace.

What you can do is use the -buildrepo instruction. If you set this to a local maven repo, it will push your artifacts to the local maven repo in ~/.m2/repository. You can consume it from there.

So if your project is in another workspace, you just open two Eclipses on each. If the other project is maven or Gradle, you just install the artifacts.

Cool recipe. Thanks :slight_smile:

How can I include the java source code along with the artifact which is pushed to the local repo?
On the consuming Eclipse instance I would like to “Add sources” , but it’s greyed out.

image

Do you have -sources: true in your bnd.bnd? This embeds the source in your bundle under OSGI-OPT/src.

It is also possible that the Maven menu item there is looking for a separate Jar file for the sources, which the Bnd Maven deployer isn’t installing. In that case we might need a patch to make it work.

1 Like

I think you need to look in your local repo? But I also think the normal maven install does not create the source jars.

You can of course always add the sources of the external maven project in Eclipse directly to your launch configuration.

That said, a simple solution might be to add the far superior solution of adding the sources in the jar as bnd does, as is outlined by father Krieg.

No. But I will try.

Yes that’s what I did.

From a user perpective I would have expected that the separate sources .jar is there and the “Add sources” menu item works.

Just thinking:
Would it make sense to add a property to the repo configuration which is used by -buildrepo so that an additional sources.jar is generated?

for example: createSourceJar=true

-plugin.maven  \
	aQute.bnd.repository.maven.provider.MavenBndRepository; \
	name=Local,\
        createSourceJar=true;
	
-buildrepo: Local

Would that be the right approach (in theory)?

Your secondary project is maven, so source creation happens there. The reading repository in the bndtools workspace has no way to find where those sources are if they are not in the appropriate ~/.m2 dir.

Yes. That is what I mean with my example.
I think I should have said, that I assumed my example repo-definition in this secondary project (the one where it is pushed to the Local repo). It would also push the .sources.jar

Then the reading repository would find it.

You can probably do this with -maven-release

1 Like