Add native OSGi bundle metadata to published jars#498
Conversation
|
@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
left a comment
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?
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
|
@trask added a test. I went with the same approach as opentelemetry-java's Two things surfaced while getting it to resolve, both scoped to the test module:
Both are documented in comments in |
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.