Documentation improvement for Copy task VS project.copy() method


(Stephane Galles) #1

The Gradle documentation says in the “How to work with files” chapter, about the Copy task :

You can also use the Project.copy() method to copy files. It works the same way as the task.

AFAICT this is far from being true, and my experience is that it confuses a lot of Gradle users.

For the Copy task, when the output of an other task is used in a ‘from’ clause, the Copy task implicitly add the child task as a dependency of the Copy task (because the output of the child task is a Buildable I guess)

For the copy() method, of course it does not happen (as the copy() method is imperatively used in the Action of an other task), and, as the copy behavior ignore the non existing files, the copy silently ignore the output of the task (or worse, the output of the child task is copied but is not up to date). If i’m not mistaken, to get the correct behavior, the user must explicitly add the child task as a dependency of the task where the copy() method is used.

Maybe this behavior should be described in the documentation.


(René Groeschke) #2

Hello Stephane, you’re right with that. Another big advantage of the Copy task compared to the copy method is the build-in up-to-date check. It would be helpful to have this explicitly in the Gradle Documentation. Maybe you’re interested in polishing the userguide in this area and send a pull request?

cheers, René


(Stephane Galles) #3

Hello Rene, thanks for the quick answer.

Indeed, I had forgotten the incremental feature too.

For the documentation, I would be glad to help. I’ll try to write something and send a pull request.


(René Groeschke) #4

Excellent!