Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileCopyDetails are incorrect if eachFile{} is called before rename{} #2721

Closed
nishantghan opened this issue Aug 14, 2017 · 4 comments
Closed
Labels

Comments

@nishantghan
Copy link

Related forum post: https://discuss.gradle.org/t/how-to-access-final-name-of-a-file-specified-in-a-rename-closure-inside-eachfile-method/23673

Expected Behavior

FileCopyDetails are correct irrespective of the order in which rename{} and eachFile{} are called.

Current Behavior

FileCopyDetails are incorrect if eachFile{} is called before rename{}

Context

We need to print a report of what all files are copied by a copy task with information such as final name of the file at destination, source file path etc. Currently if we call eachFile{} to achieve this, the 'getName()' method returns the name of the file before it is renamed by a rename{} closure which is called after eachFile{}. See example below.

Steps to Reproduce (for bugs)

task A (type: Copy) {
from 'abc.txt'
into buildDir
eachFile { fileCopyDetails ->
println "Copying ${fileCopyDetails.getName()} from ${fileCopyDetails.getSourceName()}"}
}
A.configure {
rename 'xyz.txt'
}
// Prints
Copying abc.txt from abc.txt

Your Environment

Windows 7

@oehme
Copy link
Contributor

oehme commented Aug 18, 2017

Could you please attach a zipped-up example project (including Gradle wrapper, sample files...) so we can reproduce this as quickly as possible?

@nishantghan
Copy link
Author

Attached.
Gradle_issues_2721_reproduce.zip

@stale
Copy link

stale bot commented Jul 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Jul 1, 2020
@stale
Copy link

stale bot commented Jul 22, 2020

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Jul 22, 2020
@wolfs wolfs closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants