1

I am converting the build of a bunch of OSGi bundles from Maven builds to Gradle. Part of the build includes using Bnd to embed some jars into the generated jar, as well as generate specific headers in the manifest file.

The incumbent Maven build uses the "maven-bundle-plugin" to achieve this. The plugin has an Embed-Dependency feature which appears to take the desired dependencies and embed them (as jars) in the generated jar. It also places headers in the manifest file: Bundle-ClassPath and Embedded-Artifacts. There are other de facto headers, but the two I've specified are the ones causing issues when trying to get the Gradle output to match that from Maven.

I have been able to achieve a portion of this with plain Bnd (bndtools) and Gradle,

For example, this bnd instruction:

-includeresource: docker-java-core-3.2.5.jar; lib:=true

will embed the jar docker-java-core-3.2.5.jar and add it to the Bundle-ClassPath manifest header. I haven't found a way for Bnd to include transitive depdencies, so I specify those manually, which is fine.

However, I'm unable to find a way (using plain Bnd) to add the jars to the manifest section Embedded-Artifacts which is generated by the Maven build.

This section appears in the Manifest with this format:

Embedded-Artifacts: docker-java-core-3.2.5.jar;g="com.github.docker-java";a="docker-java-core";v="3.2.5"

I'd like to produce the same using Bnd (Bndtools) through Gradle.

[edit] The comments indicate that this header is unnecessary, and isn't part of the OSGi specifications. Why might it be included, if this is the case? [/edit]

Matthew
  • 267
  • 1
  • 14
  • 2
    What does the `Embedded-Artifacts` manifest header do or mean? It is not part of the OSGi Core specification. So perhaps you don't need this manifest header? – BJ Hargrave Dec 01 '20 at 17:58
  • 1
    That header has no function as far as I know? – Peter Kriens Dec 01 '20 at 18:09
  • Thanks for the information. If that's the case, then it looks like the header is redundant and doesn't need to be in the file. Is there a reason the plugin might generate it, that you can think of? I'm quite new to OSGi, so I'm currently trying to replicate the build like-for-like rather than building with gradle from scratch knowing which components go where. It's nice to know some things (probably) don't have to map exactly. – Matthew Dec 02 '20 at 10:51
  • Perhaps it is just documentary? You would need to ask the maven-bundle-plugin developers what the purpose of the header is. – BJ Hargrave Dec 02 '20 at 13:34

0 Answers0