title: How to setup gradle distZip task to put resources into sub-directories and classpath correctly?
body: <p>I have these build.gradle files:</p>
  
  <pre><code>dependencies {
    runtime files('src/main/resources')
    runtime files('src/main/resources/cfg')
    runtime files('src/main/resources/sql')
  }
  
  jar {
    exclude 'cfg/*'
    exclude 'cfg/'
    exclude 'sql/*'
    exclude 'sql/'
  }
  </code></pre>
  
  <p>And this one</p>
  
  <pre><code>dependencies {
    runtime files('src/main/resources')
    runtime files('src/main/resources/cfg')
    runtime files('src/main/resources/fxml')
    runtime files('src/main/resources/icons')
  }
  
  jar {
    exclude 'cfg/*'
    exclude 'cfg/'
    exclude 'icons/*'
    exclude 'icons/'
    exclude 'fxml/*'
    exclude 'fxml/'
  }
  
  startScripts {
    doLast {
      def winScriptFile = file getWindowsScript()
      def winFileText = winScriptFile.text
      winFileText = winFileText.replaceAll 'set CLASSPATH=.*', 'set CLASSPATH=%APP_HOME%\\\\lib\\\\\\*;%APP_HOME%\\\\lib\\\\cfg;%APP_HOME%\\\\lib\\\\fxml;%APP_HOME%\\\\lib\\\\icons;%APP_HOME%\\\\lib\\\\sql'
    }
  }
  </code></pre>
  
  <p>I can exclude the resource directories and their files from the projectName.jar file but I am not able to exclude the files from the sub-directories from the /lib directory which the distZip/distTar tasks create.</p>
  
  <p>I want to have this layout in the zip/tar</p>
  
  <pre><code>projectName/
  |
  |-lib/
  | |
  | |-cfg/
  | | |-*.*
  | |     
  | |-fxml/
  | | |-*.fxml
  | |
  | |-icons/
  | | |-*.ico
  | |
  | |-sql/
  | | |-*.sql
  | |
  | |-*.jar
  |
  |-bin/
    |
    |-projectName.bat
  </code></pre>
  
  <p>Where all resources in the sub-directories are not included in the lib directory and the sub-directories are set in the <code>CLASSPATH</code> variable in the <code>projectName.bat</code> so that the application is able to load all resources.</p>