title: Gradle - extract file from depended jar
body: <p>I want to extract file "default.jasperreports.properties" from depended jasperreports.jar
  and put it in zip distribution with new name "jasperreports.properties"</p>
  
  <p>Sample gradle build:</p>
  
  <pre class="lang-c prettyprint-override"><code>apply plugin: 'java'
  
  task zip(type: Zip) {
      from 'src/dist'
    //  from configurations.runtime
      from extractFileFromJar("default.jasperreports.properties");
      rename 'default.jasperreports.properties', 'jasperreports.properties'
  
  }
  
  def extractFileFromJar(String fileName) {
      //    configurations.runtime.files.each { file -&gt; println file} //it's not work 
      // not finished part of build file
      FileTree tree = zipTree('someFile.zip')
      FileTree filtered = tree.matching {
          include fileName
      }
  
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      runtime 'jasperreports:jasperreports:2.0.5'
  }
  </code></pre>
  
  <p>How to get FileTree in extractFileFromJar() from dependency jasperreports-2.0.5.jar?</p>
  
  <p>In script above I use </p>
  
  <pre class="lang-c prettyprint-override"><code>FileTree tree = zipTree('someFile.zip')
  </code></pre>
  
  <p>but want to use somethink like (wrong, but human readable)</p>
  
  <pre class="lang-c prettyprint-override"><code>FileTree tree = configurations.runtime.filter("jasperreports").singleFile.zipTree
  </code></pre>
  
  <hr>
  
  <p>PS: Try to call</p>
  
  <pre class="lang-c prettyprint-override"><code>def extractFileFromJar(String fileName) {
      configurations.runtime.files.each { file -&gt; println file} //it's not work 
  ...
  </code></pre>
  
  <p>but it doesn't work with exception </p>
  
  <blockquote>
    <p>You can't change a configuration which is not in unresolved state!</p>
  </blockquote>