title: Stop Gradle from modifying my image/file attribute info on copy
body: <p>I have an application that sorts images based on attribute data such as date last modified. In my unit tests resource folder I have images test/resources/folder that get copied to a build/resources/test automatically when calling "gradle build". </p>
  
  <p>The problem is I need the files to have the same last modified date for testing. </p>
  
  <p>Is it possible to use javas Files.copy in my build script to move the data and maintain it's attributes? Or is there a way to tell gradle to stop messing with my files?</p>
  
  <p>Gradle task:</p>
  
  <pre><code>task copyImages(type :Copy){
      from 'src/test/resources'
      into 'build/resources/test'
  }
  </code></pre>
  
  <p><strong>Update:</strong> </p>
  
  <p>My solution based on feedback was to use JavaExec</p>
  
  <p><strong>Gradle Build Script:</strong></p>
  
  <pre><code>apply plugin: 'java'
  
  repositories{
      mavenCentral()
  }
  
  
  dependencies {
      testCompile group: 'junit', name: 'junit', version: '4.+'
  }
  
  task(moveImages, dependsOn: 'classes', type: JavaExec){
      main = 'com.lifehug.support.TestSupport'
      classpath = sourceSets.test.runtimeClasspath
      args 'src/test/resources/navigator', 'build/resources/test/navigator'
  }
  
  defaultTasks 'moveImages'
  </code></pre>
  
  <p>And then here is my java file to move the images</p>
  
  <p><strong>Java File:</strong></p>
  
  <pre><code>public class TestSupport{
  
      public static void main(String[] args) throws IOException { 
  
              if( args.length &lt; 2) return;
  
              final Path sourceDir = Paths.get(args[0]);
              final Path targetDir = Paths.get(args[1]);
  
              Files.walkFileTree(sourceDir, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor&lt;Path&gt;() {
  
              @Override
              public FileVisitResult preVisitDirectory(Path dir,  BasicFileAttributes attrs) throws IOException  {
                      Path target = targetDir.resolve(sourceDir.relativize(dir));
                      Files.copy(dir, target, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
                      return FileVisitResult.CONTINUE;
              }
  
              @Override
              public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                      Files.copy(file, targetDir.resolve(sourceDir.relativize(file)), StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
                  return FileVisitResult.CONTINUE;
               }
  
             });
  
      }
  
  }
  </code></pre>