Skip to content

Bundle-Activator errors when dependencies contain Activators #6867

@loetifuss

Description

@loetifuss

Creating a fat jar with Gradle and the bnd plugin fails with the message:

error: The Bundle-Activator header only supports a single type. The following types were found: org.example.Activator,org.apache.logging.log4j.util.Activator. This usually happens when a macro resolves to multiple types

A similar issue has already been reported in #5257 but is still broken in the current release of bnd (7.1.0).

I have attached a sample project that creates a fat jar by combining the log4j library with a custom Bundle-Activator. The issue can be reproduced by simply calling

gradlew jar

This yields the above error message because bnd finds a Bundle-Activator in log4j although one is explicitly specified in the bnd instructions.

tasks.named("jar", Jar) {
    from(configurations.shadow.elements.map {it.collect{zipTree(it)}})
    bundle {
        bnd(
                'Bundle-Activator': 'org.example.Activator',
                'Import-Package': '*',
                'Export-Package': 'org.example.*',
                '-removeheaders': 'Private-Package,Require-Capability',
                '-nodefaultversion': true,
                '-nouses': true,
                '-noimport': true,
                '-fixupmessages': '*wrong directory*' // apparently bnd cannot deal with multi-release JARs
        )
    }
}

bnd-example.zip

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions