Browse Source

reintroduced the forseoverwrite attribute to copydir into build.xml

and made it work as well.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267734 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
d72589dc05
3 changed files with 31 additions and 3 deletions
  1. +1
    -0
      build.xml
  2. +27
    -1
      src/main/org/apache/tools/ant/Project.java
  3. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/Copydir.java

+ 1
- 0
build.xml View File

@@ -81,6 +81,7 @@
<filter token="TIME" value="${TSTAMP}" />
<copydir src="${src.dir}"
dest="${build.classes}"
forceoverwrite="true"
filtering="on">
<include name="**/version.txt" />
</copydir>


+ 27
- 1
src/main/org/apache/tools/ant/Project.java View File

@@ -558,6 +558,19 @@ public class Project {
copyFile(new File(sourceFile), new File(destFile), filtering);
}

/**
* Convienence method to copy a file from a source to a
* destination specifying if token filtering must be used and if
* source files may overwrite newer destination files.
*
* @throws IOException
*/
public void copyFile(String sourceFile, String destFile, boolean filtering,
boolean overwrite) throws IOException {
copyFile(new File(sourceFile), new File(destFile), filtering,
overwrite);
}

/**
* Convienence method to copy a file from a source to a destination.
* No filtering is performed.
@@ -577,8 +590,21 @@ public class Project {
public void copyFile(File sourceFile, File destFile, boolean filtering)
throws IOException
{
copyFile(sourceFile, destFile, filtering, false);
}

/**
* Convienence method to copy a file from a source to a
* destination specifying if token filtering must be used and if
* source files may overwrite newer destination files.
*
* @throws IOException
*/
public void copyFile(File sourceFile, File destFile, boolean filtering,
boolean overwrite) throws IOException {

if (destFile.lastModified() < sourceFile.lastModified()) {
if (overwrite ||
destFile.lastModified() < sourceFile.lastModified()) {
log("Copy: " + sourceFile.getAbsolutePath() + " > "
+ destFile.getAbsolutePath(), MSG_VERBOSE);



+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/Copydir.java View File

@@ -112,7 +112,8 @@ public class Copydir extends MatchingTask {
String fromFile = (String) enum.nextElement();
String toFile = (String) filecopyList.get(fromFile);
try {
project.copyFile(fromFile, toFile, filtering);
project.copyFile(fromFile, toFile, filtering,
forceOverwrite);
} catch (IOException ioe) {
String msg = "Failed to copy " + fromFile + " to " + toFile
+ " due to " + ioe.getMessage();
@@ -130,7 +131,7 @@ public class Copydir extends MatchingTask {
if (forceOverwrite ||
(srcFile.lastModified() > destFile.lastModified())) {
filecopyList.put(srcFile.getAbsolutePath(),
destFile.getAbsolutePath());
destFile.getAbsolutePath());
}
}
}


Loading…
Cancel
Save