title: Including specific external library to a jar file built by Gradle
body: <p>I am trying to convert a multi module project build process from Ant to Gradle. 
  We have a common module which is used by every other module. In common module I need these dependencies to be able compile it (by gradle build)</p>
  
  <pre><code>dependencies {
      api 'com.google.guava:guava:18.0'
      api 'org.json:json:20131018'
      implementation 'org.apache.httpcomponents:httpclient:4.5.5'
      implementation 'org.jruby:jruby-complete:1.5.1'
      implementation 'org.python:jython:2.2.1'
      implementation 'com.google.code.gson:gson:2.6.2'
  }
  </code></pre>
  
  <p>Some of modules should include all dependencies needed in runtime inside result jar files. Because of this I am adding the code of module dependencies to the jar file as well. Like below:</p>
  
  <pre><code>dependencies {
      compile project(':core:common')
      compile project(':core:installer')
  }
  
  jar {
      from sourceSets.main.output
      from project(':core:common').sourceSets.main.output
      from project(':core:installer').sourceSets.main.output   
  }
  </code></pre>
  
  <p>The problem is that I want to add external libraries to the jar file as well so that I have compelete jar file. It is possible to add external libraries by adding a line to jar above like this: </p>
  
  <pre><code>jar {
      from sourceSets.main.output
      from project(':core:common').sourceSets.main.output
      from project(':core:installer').sourceSets.main.output
  
      from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
  
  }
  </code></pre>
  
  <p>But then I will have a large jar file containing all of dependencies in common module while some of them are not needed in my specific jar file. What I want is to add specific external libraries to jar file for example I want just add 'org.json:json:20131018' and  'org.apache.httpcomponents:httpclient:4.5.5' to library and ignore rest of dependencies. I couldn't find a solution for this. </p>