I\'ve prepared a very simple script, that illustrates the problem I see using Gradle 1.7 (need to stick with it because of some plugins not yet supporting newer versions).>
A Copy
task only gets executed if it has something to copy. Telling it what to copy is part of configuring the task, and therefore needs to be done in the configuration phase, rather than the execution phase. These are very important concepts to understand, and you can read up on them in the Gradle User Guide or on the Gradle Forums.
doFirst
and doLast
blocks get executed in the execution phase, as part of executing the task. Both are too late to tell the task what to copy: doFirst
gets executed immediately before the main task action (which in this case is the copying), but (shortly) after the skipped
and up-to-date
checks (which are based on the task's configuration). doLast
gets executed after the main task action, and is therefore clearly too late.