gradlebnd

Include directory of jars into bundle with bnd


I am able to successfully build a bundle with the bnd gradle plugin that includes a dependency jar, using -includeresource. However, when I try to build the directory of jar(s) to include programmatically, and try to include this entire directory into the bundle, like this:

jar {
    dependsOn copyJars
    // Build OSGI bundle, including the incompatible version of the transitive dependency
    bnd('-exportcontents': 'com.example.foo',
            '-sources': 'false',
            '-includeresource': 'build/tmp/include/=lib/; lib:=true')
}

the copyJars task works (I can see the jar file has been copied), but then I get this error:

error  : Input file does not exist: lib/
error  : Input file does not exist: lib/

which does not make sense - lib/ is not an input, it's an output.


Solution

  • That's because it was given as an input file - it's the wrong way round. It should be:

    '-includeresource': 'lib/=build/tmp/include/; lib:=true')