title: Make NON-FAT jar in Gradle on-demand
body: <p>I'm using Gradle. Usually I'm build the FAT jar. There was no problem, but at this time, I also need to make NON-FAT jar.
  I mean I want to exclude all depended library and run jar with <code>-cp</code> option like the following:</p>
  
  <p><code>java -cp "/sample1/lib/myjar.jar:/sample2/lib/depended.jar" com.example.main.Runner</code></p>
  
  <p>(In FAT jar, <code>java -jar myjar.jar</code> is the same thing and its contains <code>depended.jar</code>)</p>
  
  <p>Here is my <code>build.gradle</code>.</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'application'
  
  jar.baseName = 'myjar'
  version = ''
  def mainClass = 'com.example.main.Runner'
  mainClassName =  mainClass
  
  def defaultEncoding = 'UTF-8'
  
  repositories {
    flatDir dirs: "${projectDir}/libs"
  }
  
  dependencies {
    compile ':commons-chain:1.2'
    compile ':commons-io:2.4'
  
    testCompile ':junit:4.12'
    testCompile ':hamcrest-core:1.3'
  }
  jar {
    manifest {
        attributes 'Implementation-Version': version,
                   'Main-Class': mainClass
    }
    from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}
  }
  </code></pre>
  
  <p>I still want to keep this for usual FAT jar creation.
  So, I tried to append a task like the following:</p>
  
  <p>TRY #1</p>
  
  <pre><code>task makeSlimJar {
    jar.baseName = 'myjar.slim'
    jar {
    manifest {
        // remove main class
        attributes 'Implementation-Version': version
    }
    from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}
  }
  </code></pre>
  
  <p>TRY #2</p>
  
  <pre><code>task makeSlimJar {
    jar.baseName = 'myjar.slim'  
    jar {
    manifest {
        // remove main class
        attributes 'Implementation-Version': version
    }
    from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}
  
    tasks.Jar.execute()
  }
  </code></pre>
  
  <p>TRY #3</p>
  
  <pre><code>task makeSlimJar {
    jar.baseName = 'myjar.slim'
    jar {
    manifest {
        // remove main class
        attributes 'Implementation-Version': version
    }
    from {configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }}
    dependsOn Jar 
  }
  </code></pre>
  
  <p>After appended it, I ran the <code>gradle makeSlimJar</code>.
  All of the above my tries were failed(programmatically, it were succeeded) and just created FAT jar with name  <code>myjar.slim.jar</code>.</p>
  
  <p>Is there way to live together FAT and NON-FAT jar on the same <code>build.gradle</code> file?
  ... Or am I something wrong?</p>
  
  <p>I consider that removing <code>apply plugin: 'application'</code> for NON-FAT jar is my last resort.</p>
  
  <p>Please help me, if you could.</p>
  
  <p>Thanks,</p>