TomDmitriev / gradle-bundle-plugin

Apache License 2.0
47 stars 24 forks source link

NPE in Bnd tools when Manifest attributes contain non-String values #41

Closed xtracoder closed 8 years ago

xtracoder commented 8 years ago

I've got this (https://github.com/bndtools/bnd/issues/1270) problem while playing with that plugin.

Problem occurs when some of the jar.manifest.attributes contains non-plain-String or null value. I came across two use cases

(1). It's rather easy to put a GString into jar.manifest.attributes without having intention to do so (and i suspect this is rather common issue)

jar {
    manifest {
        attributes ('My-Attribute': "${project.name}/${project.version}")
    }
}

(2). 'org.dm.bundle' plugin does not coexist with native Gradle's 'osgi' plugin - i guess it shouldn't, but I recommend throwing explicit exception to not mislead users like with NPE exception in Bnd. Root cause - native 'osgi' plugin adds property 'Bnd-LastModified' which is stored as Long, not as `String' - that causes NPE in Bnd tools

I recommend fixing this problems:

  1. In BundleUtils.groovy - static def attributes(Manifest manifest) - check for the type of values when merging them into output
  2. check for presence of 'osgi' plugins in the set of applied plugins during startup of the 'org.dm.bundle' plugin