Skip to content

OSGi manifest headers missing from published JARs since 26.0 #4547

Open

Description

@RedN4ks

Describe the bug

Since 26.0, the published graphql-java JAR no longer contains OSGi headers (Bundle-SymbolicName, Bundle-Version, Export-Package, Import-Package). As a result, it can't be deployed as a bundle in an OSGi container, and downstream bundles built with bnd no longer get version ranges on their graphql.* imports.

Version OSGi headers in META-INF/MANIFEST.MF
24.3, 25.0, 25.1 present (Bundle-SymbolicName: graphql-java, Export-Package: graphql.*, ...)
26.0, 26.1 missing (only Manifest-Version and Automatic-Module-Name)

To Reproduce

for v in 25.1 26.0 26.1; do
  curl -s -o gj-$v.jar https://repo1.maven.org/maven2/com/graphql-java/graphql-java/$v/graphql-java-$v.jar
  echo "== $v"; unzip -p gj-$v.jar META-INF/MANIFEST.MF | grep -E '^(Bundle-SymbolicName|Export-Package)' | cut -c1-60
done

Cause

This appears to have been introduced by 4db3cc4 (#4171, Gradle 9.2.0 upgrade). That's the only change to the bnd setup between 25.0 and 26.0. The previous setup was:

shadowJar {
    convention.plugins.bundle = new aQute.bnd.gradle.BundleTaskConvention(it)
    doLast { buildBundle() }
    bnd('''...''')
}

It was replaced with:

tasks.named('shadowJar').configure {
    def bundle = extensions.findByType(BundleTaskExtension)
    if (bundle != null) {
        bundle.bnd('''...''')
    }
}

The bnd builder plugin only adds BundleTaskExtension to the jar task, so on shadowJar findByType returns null and the block is skipped silently. The doLast { buildBundle() } step was also dropped, so bnd never rewrites the manifest.

Suggested fix

The bnd Gradle plugin documents this pattern for tasks other than jar:

tasks.named('shadowJar').configure {
    def bundle = extensions.create(BundleTaskExtension.NAME, BundleTaskExtension, it)
    bundle.bnd('''...same instructions as today...''')
    doLast(bundle.buildAction())
}

I haven't built graphql-java with this change, so it's a suggestion, not a tested patch. A build check that fails if Bundle-SymbolicName is missing from the shadow JAR would stop this from happening again.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions