[GRADLE-3025] How can I expand only a particular subdirectory of a zip(Tree)? Created: 14/Feb/14 Updated: 05/Jan/17 Resolved: 05/Jan/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Task | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Duplicate | Votes: | 26 |
Description |
How can I expand contents from a zipTree in a way that only the contents of a given sub directory gets extracted |
Comments |
Comment by Gradle Forums [ 14/Feb/14 ] | |
Use an include filter: task unzip(type: Copy) { | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
Hi Peter thank you this has but this does unzip's but it extracts the all directory tree and not the contents from that given subdirectory. B---C D----E
| |
Comment by Gradle Forums [ 14/Feb/14 ] | |
> If the include is "A/D", I was expecting to have only E F In the output That's not how include works. Ideally, you could achieve your goal with rename. However, rename currently operates on file names rather than file paths. What you can do is to add another copy task/action that copies everything below A/D to a new place. Or, code a solution based on _zipTree(zipFile).visit { ... }_. | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
Thank you, Peter | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
Vote++ for a "rename" variant that can operate on full file paths | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
You can use the `eachFile {}` hook to do this. task unzip(type: Copy) { That's untested, but it should be pretty close. docs: [1]http://www.gradle.org/docs/current/ja... | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
@Luke | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
You need to specify to ignore empty dirs: task unzip(type: Copy) { | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
We actually do have directories in the structure that are empty that we would like to unzip. Any Ideas? | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
This is a limitation of the API. You could keep track of what all the directories will be in the eachFile, and use a `doLast { project.delete "remapped dir" }`. | |
Comment by Gradle Forums [ 14/Feb/14 ] | |
I'm hitting this same issue. Utility could be improved if the zipTree method took argument for a directory within the archive from which to root the tree. For example: task unzip(type: Copy) { | |
Comment by Ned Twigg [ 26/Jan/16 ] | |
I encounter this issue almost every time I try to pull a new tool into gradle land. Coming up on 2 years old. Here's how to solve this using Gulp: http://stackoverflow.com/questions/25651264/copy-only-files-inside-a-folder-in-gulp | |
Comment by Benjamin Muschko [ 15/Nov/16 ] | |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! | |
Comment by David Meibusch [ 16/Nov/16 ] | |
+1 I still believe this is a valuable use case. | |
Comment by Stalle [ 16/Nov/16 ] | |
+1, I do too. I don't understand why it should not be possible except for the extra effort to support it. Currently I typically extract everything and use only parts, wasting a lot of disk space. | |
Comment by Kenzie Togami [ 05/Jan/17 ] | |
For all tracking this, I've made a new GitHub issue at https://github.com/gradle/gradle/issues/1108. |