You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2009/06/19 15:27:21 UTC

svn commit: r786504 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/Copy.java src/main/org/apache/tools/ant/taskdefs/Sync.java src/tests/antunit/taskdefs/copy-test.xml

Author: bodewig
Date: Fri Jun 19 13:27:21 2009
New Revision: 786504

URL: http://svn.apache.org/viewvc?rev=786504&view=rev
Log:
Don't ignore missing resources in copy when failOnError is true.  PR 47362

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Copy.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.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=786504&r1=786503&r2=786504&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jun 19 13:27:21 2009
@@ -135,6 +135,12 @@
    behavior you will now need to explicitly specify the trailing *.
    Bugzilla Report 46506.
 
+ * <copy> silently ignored missing resources even with
+   failOnError="true".  If your build tries to copy non-existant
+   resources and you relied on this behavior you must now explicitly
+   set failOnError to false.
+   Bugzilla Report 47362.
+
 Fixed bugs:
 -----------
 
@@ -721,7 +727,7 @@
  * CBZip2OutputStream now has a finish method separate from close.
    Bugzilla Report 42713.
 
- * the <zip> and <unzip> family of tasks has new option to deal with
+ * the <zip> and <unzip> family of tasks has new options to deal with
    file name and comment encoding.  Please see the zip tasks'
    documentation for details.
 

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=786504&r1=786503&r2=786504&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 Jun 19 13:27:21 2009
@@ -464,6 +464,13 @@
                     while (resources.hasNext()) {
                         Resource r = (Resource) resources.next();
                         if (!r.isExists()) {
+                            String message = "Warning: Could not find resource "
+                                + r.toLongString() + " to copy.";
+                            if (!failonerror) {
+                                log(message, Project.MSG_ERR);
+                            } else {
+                                throw new BuildException(message);
+                            }
                             continue;
                         }
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java?rev=786504&r1=786503&r2=786504&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java Fri Jun 19 13:27:21 2009
@@ -36,6 +36,8 @@
 import org.apache.tools.ant.types.PatternSet;
 import org.apache.tools.ant.types.Resource;
 import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.Restrict;
+import org.apache.tools.ant.types.resources.selectors.Exists;
 import org.apache.tools.ant.types.selectors.FileSelector;
 import org.apache.tools.ant.types.selectors.NoneSelector;
 
@@ -62,6 +64,8 @@
     // Similar to a fileset, but doesn't allow dir attribute to be set
     private SyncTarget syncTarget;
 
+    private Restrict resources = null;
+
     // Override Task#init
     /**
      * Initialize the sync task.
@@ -390,7 +394,17 @@
      * @since Ant 1.7
      */
     public void add(ResourceCollection rc) {
-        myCopy.add(rc);
+        if (rc instanceof FileSet && rc.isFilesystemOnly()) {
+            // receives special treatment in copy that this task relies on
+            myCopy.add(rc);
+        } else {
+            if (resources == null) {
+                resources = new Restrict();
+                resources.add(new Exists());
+                myCopy.add(resources);
+            }
+            resources.add(rc);
+        }
     }
 
     /**

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=786504&r1=786503&r2=786504&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/copy-test.xml Fri Jun 19 13:27:21 2009
@@ -138,4 +138,16 @@
     </copy>
     <au:assertFileExists file="${output}/final/foo"/>
   </target>
+
+  <target name="testFailOnURLConnectionError"
+          description="https://issues.apache.org/bugzilla/show_bug.cgi?id=47362">
+    <mkdir dir="${output}"/>
+    <au:expectfailure>
+      <copy todir="${output}" failonerror="true" flatten="true">
+        <resources>
+          <url url="http://i-do-not-exist/"/>
+        </resources>
+      </copy>
+    </au:expectfailure>
+  </target>
 </project>