Feature request: UnzipTask

Before you stop reading and reply “you can unzip with the Copy task” please read on :smile:

Let’s consider the following buildscript

configurations {
   unzipme
} 
dependencies {
   unzipme 'foo:bar:1.0'
}
task unzip1(type:Copy) {
    configurations.unzipme.each {
        from fileTree(it)
    }
    into "$buildDir/unzip1"
} 
task unzip2 {
    inputs.files configurations.unzipme
    outputs.dir "$buildDir/unzip2"
    doLast {
        copy {
           configurations.unzipme.each {
              from fileTree(it)
           }       
           into "$buildDir/unzip2"
       }
    } 
} 

Notice how

  1. unzip1 forces configurations.unzipme to be resolved at configuration time but unzip2 does not.

  2. The UP-TO-DATE check in unzip2 will be more efficient since it can simply calculate a hash of the zip rather than unzip1 which will calculate a hash of each individual file within the zip.

I think that unzip2 is a much better implementation but is quite verbose. Is there any chance the Gradle team would consider an Unzip task? Another option is to support a transformer(s) in the copy task which would allow the zipTree(...) operation to be delayed until execution time

5 Likes