From f52d3009e69bf1f71e677cb9378af8f50a52cb52 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 11 Apr 2002 09:19:06 +0000 Subject: [PATCH] reset state in , cleanup git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272366 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/Copydir.java | 50 +++++++++++-------- .../apache/tools/ant/taskdefs/Copyfile.java | 18 ++++--- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Copydir.java b/src/main/org/apache/tools/ant/taskdefs/Copydir.java index 8d11a5bc4..2f920816b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copydir.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copydir.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights + * Copyright (c) 2000,2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,13 +60,16 @@ import java.util.Hashtable; import java.util.Enumeration; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; /** * Copies a directory. * * @author James Davidson duncan@x180.com * - * @deprecated The copydir task is deprecated. Use copy instead. + * @since Ant 1.1 + * + * @deprecated The copydir task is deprecated since Ant 1.2. Use copy instead. */ public class Copydir extends MatchingTask { @@ -112,34 +115,39 @@ public class Copydir extends MatchingTask { } if (destDir == null) { - throw new BuildException("The dest attribute must be set.", location); + throw new BuildException("The dest attribute must be set.", + location); } if (srcDir.equals(destDir)) { - log("Warning: src == dest"); + log("Warning: src == dest", Project.MSG_WARN); } DirectoryScanner ds = super.getDirectoryScanner(srcDir); - String[] files = ds.getIncludedFiles(); - scanDir(srcDir, destDir, files); - if (filecopyList.size() > 0) { - log("Copying " + filecopyList.size() + " file" - + (filecopyList.size() == 1 ? "" : "s") - + " to " + destDir.getAbsolutePath()); - Enumeration enum = filecopyList.keys(); - while (enum.hasMoreElements()) { - String fromFile = (String) enum.nextElement(); - String toFile = (String) filecopyList.get(fromFile); - try { - project.copyFile(fromFile, toFile, filtering, - forceOverwrite); - } catch (IOException ioe) { - String msg = "Failed to copy " + fromFile + " to " + toFile - + " due to " + ioe.getMessage(); - throw new BuildException(msg, ioe, location); + try { + String[] files = ds.getIncludedFiles(); + scanDir(srcDir, destDir, files); + if (filecopyList.size() > 0) { + log("Copying " + filecopyList.size() + " file" + + (filecopyList.size() == 1 ? "" : "s") + + " to " + destDir.getAbsolutePath()); + Enumeration enum = filecopyList.keys(); + while (enum.hasMoreElements()) { + String fromFile = (String) enum.nextElement(); + String toFile = (String) filecopyList.get(fromFile); + try { + project.copyFile(fromFile, toFile, filtering, + forceOverwrite); + } catch (IOException ioe) { + String msg = "Failed to copy " + fromFile + " to " + + toFile + " due to " + ioe.getMessage(); + throw new BuildException(msg, ioe, location); + } } } + } finally { + filecopyList.clear(); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Copyfile.java b/src/main/org/apache/tools/ant/taskdefs/Copyfile.java index 6e6e714ea..a797c478d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Copyfile.java +++ b/src/main/org/apache/tools/ant/taskdefs/Copyfile.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000 The Apache Software Foundation. All rights + * Copyright (c) 2000,2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,10 @@ import org.apache.tools.ant.BuildException; * * @author duncan@x180.com * - * @deprecated The copyfile task is deprecated. Use copy instead. + * @since Ant 1.1 + * + * @deprecated The copyfile task is deprecated since Ant 1.2. Use + * copy instead. */ public class Copyfile extends Task { @@ -96,7 +99,8 @@ public class Copyfile extends Task { log("DEPRECATED - The copyfile task is deprecated. Use copy instead."); if (srcFile == null) { - throw new BuildException("The src attribute must be present.", location); + throw new BuildException("The src attribute must be present.", + location); } if (!srcFile.exists()) { @@ -105,14 +109,16 @@ public class Copyfile extends Task { } if (destFile == null) { - throw new BuildException("The dest attribute must be present.", location); + throw new BuildException("The dest attribute must be present.", + location); } if (srcFile.equals(destFile)) { - log("Warning: src == dest"); + log("Warning: src == dest", Project.MSG_WARN); } - if (forceOverwrite || srcFile.lastModified() > destFile.lastModified()) { + if (forceOverwrite + || srcFile.lastModified() > destFile.lastModified()) { try { project.copyFile(srcFile, destFile, filtering, forceOverwrite); } catch (IOException ioe) {