title: How do I exclude all subdirectories from Gradle zip task using Ant include/exclude pattern?
body: <p>I want to create a task that will zip up all the files in a directory, ignoring all subdirectories. At the same time, I want to iterate through all the subdirectories and create zips that include the files in those directories (and ignoring any further subdirectories).</p>
  
  <p>Thus, for this directory structure, I want the following zips:</p>
  
  <pre><code>$ls build/dirA
  fileA
  dirB
  
  $ls build/dirA/dirB
  fileB
  
  I should get zip/zipA containing fileA, zip/zipB containing fileB.
  </code></pre>
  
  <p>I am using code based on the answer here: <a href="https://stackoverflow.com/questions/43551572/gradle-task-to-zip-multiple-directories-independently/43552558">gradle task to zip multiple directories independently</a>  Essentially, I create a zip task for each zip artifact to be created, with a dependency on the top level task.</p>
  
  <pre><code>task myZip() {
      file('build').eachDir { dir -&gt;
          dir.eachDir { sub -&gt;
              dependsOn tasks.create("zip$sub.name", Zip) {
                  from sub
                  baseName sub.name
                  destinationDir file('zip')
              }
          }
  
          dependsOn tasks.create("zip$dir.name", Zip) {
              from dir
              baseName dir.name
              excludes ['*/**']
              destinationDir file('zip')
          }
      }
  }
  </code></pre>
  
  <p>The problem seems to be in the exclude pattern.  I get the correct zips for the sub directories, but the parent directory includes <code>fileA</code> and <code>dirB/fileB</code>.</p>
  
  <p>What is the correct way to do this please?</p>
  
  <p>*Note I have not put an exclude for the iteration through the subdirectories, as I figure this pattern needs to be the same as for the parent directory, which I haven't figured out yet.</p>