From 6f56a472615800182acf303da5c6358dbe59ed90 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 27 Jul 2011 07:34:45 +0000 Subject: [PATCH] support multiple resource collections in sync. PR 51462 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1151369 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 3 +++ manual/Tasks/sync.html | 3 +-- src/main/org/apache/tools/ant/taskdefs/Sync.java | 5 ++++- src/tests/antunit/taskdefs/sync-test.xml | 9 +++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 79dec794f..cc13a8fda 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -67,6 +67,9 @@ Fixed bugs: when Ant is used via its Java API. Bugzilla Report 51161 + * only supported a single non-fileset resource collection even + though the manual said it could be multiple. + Other changes: -------------- diff --git a/manual/Tasks/sync.html b/manual/Tasks/sync.html index b1f77c580..1d34aeef5 100644 --- a/manual/Tasks/sync.html +++ b/manual/Tasks/sync.html @@ -98,8 +98,7 @@ dir, it will get removed from the target.

fileset or any other resource collection

Resource -Collections are used to select groups of files to copy. To use a -resource collection, the todir attribute must be set.

+Collections are used to select groups of files to copy.

Prior to Ant 1.7 only <fileset> has been supported as a nested element.

diff --git a/src/main/org/apache/tools/ant/taskdefs/Sync.java b/src/main/org/apache/tools/ant/taskdefs/Sync.java index 8f7ade95f..1f7210ae1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Sync.java +++ b/src/main/org/apache/tools/ant/taskdefs/Sync.java @@ -36,6 +36,7 @@ import org.apache.tools.ant.types.FileSet; 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.Resources; 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; @@ -65,6 +66,7 @@ public class Sync extends Task { private SyncTarget syncTarget; private Restrict resources = null; + private Resources nestedResources = null; // Override Task#init /** @@ -401,9 +403,10 @@ public class Sync extends Task { if (resources == null) { resources = new Restrict(); resources.add(new Exists()); + resources.add(nestedResources = new Resources()); myCopy.add(resources); } - resources.add(rc); + nestedResources.add(rc); } } diff --git a/src/tests/antunit/taskdefs/sync-test.xml b/src/tests/antunit/taskdefs/sync-test.xml index 821a95603..e6b202a3d 100644 --- a/src/tests/antunit/taskdefs/sync-test.xml +++ b/src/tests/antunit/taskdefs/sync-test.xml @@ -142,4 +142,13 @@ + + + + + + + +