title: Rake - Copy only changed files
body: <p>So I have a rake file like the following:</p>
  
  <pre><code>require 'fileutils'
  
  task :copy do
    FileUtils.cp_r 'src', 'target'
  end
  </code></pre>
  
  <p>How can I:</p>
  
  <ol>
  <li>Only copy the files that have changed?</li>
  <li>Make the <code>:copy</code> task have a dependency on the <code>src</code> directory so that it will only launch if it needs to? <code>:copy =&gt; 'src'</code> and <code>:copy =&gt; FileList['src/*'].to_a</code> don't seem to work.</li>
  </ol>
  
  <p>I can take care of the first question like this:</p>
  
  <pre><code>task :copy do
      sh 'rsync -ru src/* target'
  end
  </code></pre>
  
  <p>I would like to, if reasonably possible, do this with only ruby / rake. This also <em>somewhat</em> takes care of the second question because <code>rsync</code> won't do anything if no files have changed, but I would like for the rake task to not execute at all if possible.</p>