Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 48293 invoked from network); 9 Apr 2010 04:44:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Apr 2010 04:44:01 -0000 Received: (qmail 72042 invoked by uid 500); 9 Apr 2010 04:44:01 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 71957 invoked by uid 500); 9 Apr 2010 04:44:00 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 71934 invoked by uid 99); 9 Apr 2010 04:44:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Apr 2010 04:44:00 +0000 X-ASF-Spam-Status: No, hits=-1300.9 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Apr 2010 04:43:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AF8AB2388A2C; Fri, 9 Apr 2010 04:43:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r932241 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Copy.java src/tests/antunit/taskdefs/copy-test.xml Date: Fri, 09 Apr 2010 04:43:38 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100409044338.AF8AB2388A2C@eris.apache.org> Author: bodewig Date: Fri Apr 9 04:43:38 2010 New Revision: 932241 URL: http://svn.apache.org/viewvc?rev=932241&view=rev Log: make failonerror work as expected when copying to a file instead of a directory Modified: ant/core/trunk/WHATSNEW ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=932241&r1=932240&r2=932241&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Fri Apr 9 04:43:38 2010 @@ -71,6 +71,10 @@ Fixed bugs: * 's sourcebase attribute was broken. Bugzilla Report 48970 + * 's failonerror didn't work as expected when copying a single + element resource collection to a file. + Bugzilla Report 49070 + Other changes: -------------- Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java?rev=932241&r1=932240&r2=932241&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java Fri Apr 9 04:43:38 2010 @@ -66,6 +66,9 @@ import org.apache.tools.ant.util.FlatFil * @ant.task category="filesystem" */ public class Copy extends Task { + private static final String MSG_WHEN_COPYING_EMPTY_RC_TO_FILE = + "Cannot perform operation from directory to file."; + static final File NULL_FILE_PLACEHOLDER = new File("/NULL_FILE"); static final String LINE_SEPARATOR = System.getProperty("line.separator"); // CheckStyle:VisibilityModifier OFF - bc @@ -395,10 +398,22 @@ public class Copy extends Task { // will be removed in validateAttributes savedRc = (ResourceCollection) rcs.elementAt(0); } + + try { // make sure we don't have an illegal set of options + try { validateAttributes(); + } catch (BuildException e) { + if (failonerror + || !getMessage(e) + .equals(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE)) { + throw e; + } else { + log("Warning: " + getMessage(e), Project.MSG_ERR); + return; + } + } - try { // deal with the single file copySingleFile(); @@ -631,8 +646,7 @@ public class Copy extends Task { + " files."); } if (rc.size() == 0) { - throw new BuildException( - "Cannot perform operation from directory to file."); + throw new BuildException(MSG_WHEN_COPYING_EMPTY_RC_TO_FILE); } else if (rc.size() == 1) { Resource res = (Resource) rc.iterator().next(); FileProvider r = (FileProvider) res.as(FileProvider.class); Modified: ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml?rev=932241&r1=932240&r2=932241&view=diff ============================================================================== --- ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml (original) +++ ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml Fri Apr 9 04:43:38 2010 @@ -188,4 +188,69 @@ public class NullByteStreamResource exte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +