title: Creating Osgi Bundle with dependent Jars using Gradle
body: <p>I would like to create some bundles which dependent on some other (3rd party) jars
  (whether this is a good practice is another topic)</p>
  
  <p>I am able to use gradle to generate a fat jar (which has all dependent jars) and the osgi manifest </p>
  
  <p>My project Layout store jars in the libs/ folder
  After making the jar, 3rd party jars (e.g. ibm.jar) are in the root of the jar.</p>
  
  <p>I will My gradle task is using the osgi plugin with some basic osgi instruction, I specified only  the export package as my program's package manually, but not other 3 jars</p>
  
  <p>However, when I try to install that bundle it shows error</p>
  
  <pre><code>Error starting file:****.jar (org.osgi.framework.BundleException: Unresol
  ved constraint in bundle ***** [24]: Unable to resolve 24.0: missi
  ng requirement [24.0] osgi.wiring.package; (osgi.wiring.package=com.ibm.mq))
  org.osgi.framework.BundleException: Unresolved constraint in bundle **** [24]: Unable to resolve 24.0: missing requirement [24.0] osgi.wiring.package; (osgi.wiring.package=com.ibm.mq)
          at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:382
  6)
          at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
          at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
  
          at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStart
  LevelImpl.java:295)
          at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>Gradle </p>
  
  <pre><code>task makeJar(type: Jar) {
  
  from { 'libs/'}
  manifest = osgiManifest {
          classesDir = sourceSets.main.output.classesDir
          classpath = sourceSets.main.runtimeClasspath
          instruction 'Export-Package','abc.def'  
          instruction 'Bundle-Vendor', 'ABC'
          instruction 'Bundle-Activator', 'abc.def.Activator'
          instruction 'Bundle-ClassPath', '.,*.jar'
          instruction 'Include-Resource', '@**/*.jar'
      }
  }
  </code></pre>
  
  <p>I tried with below but it wont work, seems an issue of gradle  <a href="http://issues.gradle.org/browse/GRADLE-1107" rel="noreferrer">http://issues.gradle.org/browse/GRADLE-1107</a></p>
  
  <pre><code>'Include-Resource', 'libs/'
  </code></pre>
  
  <p>I tried to explicity set them in classpath, but problem persist</p>
  
  <pre><code>Bundle-ClassPath: '.,*.jar' 
  </code></pre>
  
  <p>I can see the package I need (com.ibm.mq) is in Import-Package:
  is that correct?</p>
  
  <p>My question is : 
  what should be the correct manifest?
  Can the gradle (based on BND) understand the dependencies and automatically create the manifest, if so what is the required setup?</p>
  
  <p><em>EDIT</em>:
  With my gradle insturction like this, i am getting same error
  (I checked the bundle Class path appear in the manifest as well)</p>
  
  <pre><code>instruction 'Bundle-ClassPath', """.,felix.jar,org.springframework.aop-3.0.5.RELEASE.jar,org.springframework.asm-3.0.5.RELEASE.jar,c3p0-0.9.1.2.jar,com.springsource.net.sf.cglib-2.2.0.jar,org.springframework.context-3.0.5.RELEASE.jar,org.springframework.transaction-3.0.5.RELEASE.jar,com.ibm.mqjms.jar,org.springframework.beans-3.0.5.RELEASE.jar,org.springframework.core-3.0.5.RELEASE.jar,commons-io-1.4.jar,org.springframework.expression-3.0.5.RELEASE.jar,ojdbc14.jar,org.springframework.jdbc-3.0.5.RELEASE.jar,connector.jar,commons-lang-2.4.jar,commons-logging.jar,com.ibm.mq.jar,log4j-1.2.15.jar,org.springframework.web-3.0.5.RELEASE.jar"""
  </code></pre>