Hi Adam,

Adam Murdoch schrieb:


On 12/01/10 1:26 PM, RenŽé Gröschke wrote:
Hi there,
I know there was a discussion going on to improve the file handling of gradle including archive extracting stuff. Is there already an easy built-in way to extract a tar.gz and/or a "normal" zip file? This is an exercise for the copyspec isn't it? Unfortunately I'm not familiar with this copyspec stuff yet.


You can use the zipFile() and tarFile() methods. These return FileTree impls which will iterate over the contents of a ZIP or TAR file, respectively.

Then, depending on what you want to do, you can:

- Use the FileTree API to, for example, iterate over each file in the ZIP/TAR:

zipFile('someFile.zip').each { file -> println "doing something with $file" } zipFile('someFile.zip').visit { fte -> println "visiting entry $fte.name" }

- Pass the tree to the Copy task or method to extract the ZIP/TAR into a directory:

copy {
    from zipFile('someFile.zip')
    into 'some-dir'
}

copy {
   from zipTree('someFile.zip')
   into 'some-dir'
}

did the job.

--
------------------------------------
Rene Groeschke

[email protected]
http://www.breskeby.com
------------------------------------


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to