Actually the from closure is evauluated when building the task graph, which is a phase right between configuration time and execution time. We generally don’t mention that since it rarely makes a difference.
It has to be evaluated at that point to make sure we’re getting all task dependencies right. It is however only evaluated if the task is part of those that need to be run for that build.
Your case stretches the basic copy task beyond its limit. I suggest you write a custom task which takes the sources.txt as an input file and then uses the project.copy() method inside the task action.
@Rene The closure you showed is a different one which will be evaluated at configuration time. It is meant to configure a subspec. The closure that @crazyjavahacking showed is a lazy file collection on the other hand which is evaluated when building the task graph.