The doc says:
https://docs.gradle.org/current/userguide/osgi_plugin.html
If the Java plugins is applied, the OSGi plugin replaces the manifest object of the default jar with an OsgiManifest object. The replaced manifest is merged into the new one.
It appears that all attributes added to JAR manifest before applying OSGI plugin are just ignore.
Here is the test build.gradle
apply plugin: 'java'
jar.manifest.attributes(dummy: 'dummy-value')
println "Attributes = " + jar.manifest.attributes
apply plugin: 'osgi'
println "Attributes = " + jar.manifest.attributes
println "Instructions = " + jar.manifest.instructions
classes << {
file("${buildDir}/classes/main/").mkdirs()
}
Console output:
C:\...\jar-osgi-test>gradle build
Attributes = [Manifest-Version:1.0, dummy:dummy-value]
Attributes = [Manifest-Version:1.0]
Instructions = [:]
:compileJava UP-TO-DATE
...
Content of MANIFEST.MF
Manifest-Version: 1.0
Bundle-SymbolicName: jar-osgi-test
Bundle-Version: 0.0.0.unspecified
Bundle-Name: jar-osgi-test
Bundle-ManifestVersion: 2
Bnd-LastModified: 1450192516497
Created-By: 1.8.0_66 (Oracle Corporation)
Tool: Bnd-2.4.0.201411031534
My ‘dummy’ attribute is lost with OSGI plugin.