Depending on which version of the JDK you run Gradle with, any method that receives a FileTreeElement (mainly FileTree/FileCollection visit and eachFile FileCopyDetails) could see different behavior when calling getSize and getLastModified methods.
For JDK6, Gradle will usually return the size and last modified time of the underlying file at the time it is asked for. Any subsequent calls will return the same cached value.
For JDK7+, Gradle will usually return the size and last modified time of the underlying file when the file's parent has been visited. Any subsequent calls will return the same cached value.
In some cases, changes to the file will be reflected every time when calling getSize or getLastModified.
This inconsistency could cause problems if a task modifies files while visiting them and expects to see those changes reflected in the FileVisitDetails/FileTreeElement/FileCopyDetails getSize or getLastModified properties. This is uncommon behavior in most builds.
We plan to make this behavior consistent by always caching these values when the parent is visited. If you never want to see the cached values, we recommend using getFile().size() or getFile().lastModified() instead. This goes directly to the underlying file.