[GRADLE-2256] FileCopyDetails.setMode() from within copy { from zipTree() eachFile { ... } } doesn't work Created: 26/Apr/12  Updated: 04/Jan/13  Resolved: 15/May/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-rc-1
Fix Version/s: None

Type: Bug
Reporter: Bob Glamm Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 0


 Description   

The following fails to correctly set the file mode on files ending with ".sh" in "archive.zip":

copy {
from zipTree("archive.zip")
eachFile {
if (it.getName().endsWith(".sh"))

{ it.setMode(0755) }

}
into "targetDir"
}

If the ".sh" files included in the ZIP are mode 0644, they get copied from the ZIP into "targetDir" as mode 0644, not mode 0755 as requested by the code in eachFile(). (Adding a println to the "if" condition in the eachFile closure shows that the files are getting correctly matched and having the setMode() method called, but this seems to have no effect on the copied files.)



 Comments   
Comment by René Gröschke (Inactive) [ 13/May/12 ]

this seems to be a bug with the eachFile closure. I can reproduce this issue with the following more simple snippet:

task myCopy(type:Copy) {
from "test"
eachFile {
if (it.getName().endsWith(".sh"))

{ it.setMode(0755) }

}
into "targetDir"
}

Generated at Wed Jun 30 12:16:58 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.