Browse Source

Made sure file ignored command to copy over itself.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268226 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 24 years ago
parent
commit
767f4f5785
2 changed files with 9 additions and 3 deletions
  1. +1
    -1
      src/etc/testcases/taskdefs/copy.xml
  2. +8
    -2
      src/main/org/apache/tools/ant/taskdefs/Copy.java

+ 1
- 1
src/etc/testcases/taskdefs/copy.xml View File

@@ -3,7 +3,7 @@
<project name="copy-test" basedir="." >

<target name="test1">
<copy file="copy.xml" todir="."/>
<copy file="copy.xml" todir="." overwrite="true"/>
</target>

</project>

+ 8
- 2
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -187,7 +187,7 @@ public class Copy extends Task {
if (destFile == null) {
destFile = new File(destDir, file.getName());
}
if (forceOverwrite ||
(file.lastModified() > destFile.lastModified())) {
fileCopyMap.put(file.getAbsolutePath(), destFile.getAbsolutePath());
@@ -290,7 +290,7 @@ public class Copy extends Task {
for (int i = 0; i < toCopy.length; i++) {
File src = new File(fromDir, toCopy[i]);
File dest = new File(toDir, mapper.mapFileName(toCopy[i])[0]);
map.put(src.getAbsolutePath(), dest.getAbsolutePath());
map.put( src.getAbsolutePath(), dest.getAbsolutePath() );
}
}

@@ -309,8 +309,14 @@ public class Copy extends Task {
String fromFile = (String) e.nextElement();
String toFile = (String) fileCopyMap.get(fromFile);

if( fromFile.equals( toFile ) ) {
log("Skipping self-copy of " + fromFile, verbosity);
continue;
}

try {
log("Copying " + fromFile + " to " + toFile, verbosity);
project.copyFile(fromFile,
toFile,
filtering,


Loading…
Cancel
Save