Repackage jar as bundle

I’d like to repackage a third party jar as an OSGi bundle.

Right now I have the following, which is based on OSGi uberjar recipe from dexterous (

apply plugin: 'java'
apply plugin: 'osgi'
  configurations {
  dependencies {
    uberJar "bla:bla:ver"
  classes {
 doLast {
     // without this, the jar task fails with "java.lang.IllegalArgumentException: A Jar can only accept a valid file or directory:" as underlying cause
  ant.mkdir(dir: "$buildDir/classes/main")
  jar {
 configurations.uberJar.each { from zipTree(it) }
    manifest {
        instruction 'Export-Package', 'bla.bla', 'bla.bla.api'
        attributes 'Bundle-Name': 'bla-bundle'
        attributes 'Bundle-Version': '1.0.0'
        instruction 'Bundle-Vendor', 'my company'
        attributes 'Bundle-SymbolicName':'bla.bla'

This succeeds in creating a bundle with the contents defined in the uberJar dependency.

The problem is in defining the Export-Package. The actual packages in the bundle are not exported, and the explicit instruction is ignored.

Any suggestions on how I can get this working?