title: How to avoid that Gradle's osgi plugin generates export-pacakge entry for private packages and import-package entry for embedded dependencies
body: <p>Dear StackOverflow users</p>
  
  <p>I have a gradle project of which I want to turn the artifact into an osgi bundle. In this bundle I have:</p>
  
  <ul>
  <li>packages that I don't want to export (may not appear in manifest's <code>Export-Package</code> entry)</li>
  <li>dependencies that I want to embed (may not appear in manifest's <code>Import-Package</code> entry)</li>
  </ul>
  
  <p>After a bit of tinkering I have come up with the following <code>gradle.build</code> file which does what I intend but maybe not in the cleanest way possible, leveraging bnd...</p>
  
  <pre><code>group 'com.mycompany'
  version '1.0.0'
  
  apply plugin: 'java'
  apply plugin: 'osgi'
  
  repositories {
      jcenter()
  }
  
  dependencies{
      compile 'org.osgi:org.osgi.framework:1.8.0'  //provided
      compile 'com.google.code.gson:gson:2.8.0'    //embedded
  }
  
  
  jar {
      //embedding the gson dependency
      from({
          def x = configurations.compile.find({
              return it.getName().contains('gson')
          })
          def tree = zipTree(x)
          return tree
      })
  
      //explicitly building manifest entries
      manifest {
          instruction 'Bundle-Vendor',
                  'My Company'
          instruction 'Bundle-Activator',
                  'com.mycompany.mybundle.Activator'
          instruction 'Import-Package',
                  '!com.google.gson',           
                  '*'
          instruction 'Export-Package',
                  /com.mycompany.mybundle;version="${version}"/
      }
  }
  </code></pre>
  
  <p>Is it possible to accomplish this in a cleaner way?  I mainly want to avoid two things:</p>
  
  <ol>
  <li>having to manually write the import and export-package entries</li>
  <li>having to manually copy the contents of the embedded dependencies (gson) into my jar </li>
  </ol>
  
  <p>I thought bnd (underlying the osgi plugin) could do that for me, but with what I have tried so far (even if I add them as private package) bnd still exports everything and imports the gson package as well as it won't add the gson classes to the jar</p>