title: Using Gradle to build a jar with dependencies with Kotlin-DSL
body: <p>There is already an answer to the question: <a href="https://stackoverflow.com/a/4894308/5247292">how to include all the dependencies in a jar file</a> though it's for Groovy</p>
  
  <p>I'm using gradle with <code>kotlin-dsl</code> and the code is not compatible. I tried to make it work using a few ways including: </p>
  
  <pre><code>tasks.withType&lt;Jar&gt; {
      configurations["compileClasspath"].forEach { file: File -&gt;
          copy {
              from(zipTree(file.absoluteFile))
          }
      }
  }
  </code></pre>
  
  <p>Though this doesn't work. So how to include the dependencies using <code>kotlin-dsl</code> in gradle?</p>