title: How can I create a zip in gradle from a list of files?
body: <p>This is most certainly a gradle newbie question but it's really beating me up.  My source tree looks like this:</p>
  
  <pre><code>|-- master
      buildSrc
      build.gradle
  |-- comp1
      !-- filea
      !-- fileb
  |-- comp2
      !-- file1
      !-- file2
      !-- etc
  </code></pre>
  
  <p>I'm running the <code>build.gradle</code> in the <code>master</code> directory which uses a custom task (called in prepBundle (not shown)) to produce a list of files which need to be in a zip file. There is some various external processing that goes into the list so there isn't a way to use any basic includes or closures to come up with the list.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>task showFilelist(dependsOn:prepBundle){ 
    prepBundle.outputs.files.each{ 
      println "including file: ${it}"
    }
  }
  
  task createBundle(type:Zip,dependsOn:prepBundle){ 
    inputs.files(prepBundle.outputs.files)
    outputs.file(archiveName)
    baseName = "somebundle"
    from ".."
    include prepBundle.outputs.files
  }
  </code></pre>
  
  <p>If I just run showFilelist, I do get the correctly resolved paths to the files I want to zip:</p>
  
  <pre><code>&lt;snip&gt;
  :showFilelist
  including file: C:\fullpath\master\build.gradle
  including file: C:\fullpath\comp1\filea
  including file: C:\fullpath\comp2\file1
  </code></pre>
  
  <p>But when I run my bundling task, it blows up:</p>
  
  <pre><code>:createBundle
  
  FAILURE: Build aborted because of an internal error.
  
  * What went wrong:
  Build aborted because of an unexpected internal error. Please file an issue at: http://forums.gradle.org.
  
  * Try:
  Run with --debug option to get additional debug info.
  
  * Exception is:
  org.gradle.api.UncheckedIOException: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
          at org.gradle.util.hash.HashUtil.createHash(HashUtil.java:56)
          at org.gradle.util.hash.HashUtil.createHash(HashUtil.java:34)
          at org.gradle.api.internal.changedetection.state.DefaultHasher.hash(DefaultHasher.java:24)
          at org.gradle.api.internal.changedetection.state.CachingHasher.hash(CachingHasher.java:45)
          at org.gradle.api.internal.changedetection.state.DefaultFileSnapshotter$1.run(DefaultFileSnapshotter.j
  ava:48)
          at org.gradle.internal.Factories$1.create(Factories.java:22)
          at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:143)
          at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:131)
          at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.
  </code></pre>
  
  <p>In prepBundle I iterate the list of files and there isn't any file being used by another process.  I don't believe it's a gradle problem, I think it's something I'm doing wrong with the configuration of the zip task.  If I change the <code>createBundle</code> a bit to drop the inputs and outputs, it looks like this:</p>
  
  <pre><code>task createBundle(type:Zip,dependsOn:prepBundle){ 
    baseName = "somebundle"
    include prepBundle.outputs.files
  }
  </code></pre>
  
  <p>But then doesn't do anything:</p>
  
  <pre><code>:createBundle UP-TO-DATE
  
  BUILD SUCCESSFUL
  </code></pre>
  
  <p>How should I put this zip together when I just have a list of files and the parent root directory for the files are not under my current project?</p>
  
  <p>Thanks for any help!</p>
  
  <ul>
  <li>Andy</li>
  </ul>