title: Gradle filetree lazy flat copy
body: <p>I have a task that needs to copy files that are created during the execution phase (they're products of a gcov unit-testing phase) into another directory.  At the moment, my code will only execute properly the second time it is executed (i.e. when files in the directory structure have been created).  The first time round, however, I get a "skipping task, no source files" debug message.</p>
  
  <pre><code>task copyGcovObj(type: Copy, dependsOn: 'test') {
      description "Copies gcov files into build/testOutput directory."
      from fileTree(dir: "$buildDir/objectFiles", includes: ["**/*.gcno", "**/*.gcda"]).files
      into ("$buildDir/testOutput")
  }
  </code></pre>
  
  <p>The code is taken from here: <a href="http://forums.gradle.org/gradle/topics/how_do_i_flatten_when_copy" rel="nofollow">Flat copy</a>.  The task 'test' referred to is a task that executes the unit tests.</p>
  
  <p>I think the problem is that during the configuration phase, there are no files to copy, so Gradle skips the task.  If it is executed a second time, Gradle sees there are files, so executes the copy.  How can I make it so that Gradle executes the copy, but the files to be copied are determined at the execution phase?</p>