Browse Source

Don't ignore missing resources in copy when failOnError is true. PR 47362

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@786504 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
38db83d1c8
4 changed files with 41 additions and 2 deletions
  1. +7
    -1
      WHATSNEW
  2. +7
    -0
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  3. +15
    -1
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  4. +12
    -0
      src/tests/antunit/taskdefs/copy-test.xml

+ 7
- 1
WHATSNEW View File

@@ -135,6 +135,12 @@ Changes that could break older environments:
behavior you will now need to explicitly specify the trailing *. behavior you will now need to explicitly specify the trailing *.
Bugzilla Report 46506. 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: Fixed bugs:
----------- -----------


@@ -721,7 +727,7 @@ Other changes:
* CBZip2OutputStream now has a finish method separate from close. * CBZip2OutputStream now has a finish method separate from close.
Bugzilla Report 42713. 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' file name and comment encoding. Please see the zip tasks'
documentation for details. documentation for details.




+ 7
- 0
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -464,6 +464,13 @@ public class Copy extends Task {
while (resources.hasNext()) { while (resources.hasNext()) {
Resource r = (Resource) resources.next(); Resource r = (Resource) resources.next();
if (!r.isExists()) { 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; continue;
} }




+ 15
- 1
src/main/org/apache/tools/ant/taskdefs/Sync.java View File

@@ -36,6 +36,8 @@ import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.PatternSet; import org.apache.tools.ant.types.PatternSet;
import org.apache.tools.ant.types.Resource; import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection; 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.FileSelector;
import org.apache.tools.ant.types.selectors.NoneSelector; import org.apache.tools.ant.types.selectors.NoneSelector;


@@ -62,6 +64,8 @@ public class Sync extends Task {
// Similar to a fileset, but doesn't allow dir attribute to be set // Similar to a fileset, but doesn't allow dir attribute to be set
private SyncTarget syncTarget; private SyncTarget syncTarget;


private Restrict resources = null;

// Override Task#init // Override Task#init
/** /**
* Initialize the sync task. * Initialize the sync task.
@@ -390,7 +394,17 @@ public class Sync extends Task {
* @since Ant 1.7 * @since Ant 1.7
*/ */
public void add(ResourceCollection rc) { 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);
}
} }


/** /**


+ 12
- 0
src/tests/antunit/taskdefs/copy-test.xml View File

@@ -138,4 +138,16 @@ public class NullByteStreamResource extends Resource {
</copy> </copy>
<au:assertFileExists file="${output}/final/foo"/> <au:assertFileExists file="${output}/final/foo"/>
</target> </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> </project>

Loading…
Cancel
Save