Add native OSGi bundle metadata to published jars#498
Open
royteeuwen wants to merge 2 commits into
Open
Conversation
Wire the bnd Gradle plugin into the shared otel.java-conventions plugin so the semconv and semconv-incubating jars are published with OSGi manifest headers (Bundle-SymbolicName, Export-Package, Import-Package). This lets the artifacts be consumed directly in OSGi containers without external re-wrapping. Fixes open-telemetry#494
Author
|
@trask anything I can do to get this mergeable? |
There was a problem hiding this comment.
Pull request overview
This PR adds native OSGi bundle metadata to the published semconv and semconv-incubating JARs by wiring the Bnd Gradle plugin into the shared otel.java-conventions build logic, enabling direct consumption in OSGi containers without wrapper bundles.
Changes:
- Adds the
biz.aQute.bnd.builderplugin to the sharedotel.java-conventionsprecompiled script plugin and configures the mainjartask to emit OSGi headers (exportingio.opentelemetry.*and auto-detecting imports). - Introduces
osgiEnabled(defaulttrue) andosgiOptionalPackagesextension knobs to control/augment OSGi import behavior. - Adds the Bnd Gradle plugin dependency to
buildSrcand enables reproducible archive settings for JAR outputs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts | Applies/configures Bnd for OSGi metadata on the main jar and enables reproducible archive output. |
| buildSrc/src/main/kotlin/io/opentelemetry/gradle/OtelJavaExtension.kt | Adds extension properties to control enabling OSGi metadata and optional import packages. |
| buildSrc/build.gradle.kts | Adds the Bnd Gradle plugin dependency to the build logic classpath. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
trask
reviewed
Jul 14, 2026
trask
left a comment
Member
There was a problem hiding this comment.
can you add a test?
or, related to open-telemetry/opentelemetry-java-instrumentation#18995, is there maybe another way / tool we could validate a jar for osgi compliance?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #494
Publishes the
semconvandsemconv-incubatingjars with OSGi bundle metadata so they can be consumed directly in OSGi containers, without external re-wrapping (e.g. hand-maintained wrapper bundles).This mirrors the OSGi support recently added to opentelemetry-java: the bnd Gradle plugin (
biz.aQute.bnd.builder) is wired into the sharedotel.java-conventionsplugin and driven byOtelJavaExtension. Since the semconv modules have no SPI / ServiceLoader needs, the configuration is a trimmed-down version of the upstream one (no ServiceLoader mediator capabilities).Changes
buildSrc/build.gradle.kts— add thebiz.aQute.bnd:biz.aQute.bnd.gradleplugin dependency.OtelJavaExtension— addosgiEnabled(defaulttrue) andosgiOptionalPackagesknobs.otel.java-conventions.gradle.kts— applybiz.aQute.bnd.builder, make archives reproducible, and configure the mainjartask's bundle with-exportcontents: io.opentelemetry.*plus an auto-detectingImport-Package. Both modules (and any future module) are bundled automatically; the-sources/-javadocjars are left plain.Generated manifest (excerpt)
opentelemetry-semconv:opentelemetry-semconv-incubating:Testing
./gradlew buildpasses (unit tests, checkstyle, japicmp, animal-sniffer).-sources/-javadocjars remain plain.