Author: bodewig
Date: Wed Jul 27 08:50:44 2011
New Revision: 1151386
URL: http://svn.apache.org/viewvc?rev=1151386&view=rev
Log:
when working on resources <sync> forgot about the source resources that are not
out-of date. PR 51462
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Sync.java
ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1151386&r1=1151385&r2=1151386&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Wed Jul 27 08:50:44 2011
@@ -70,6 +70,9 @@ Fixed bugs:
* <sync> only supported a single non-fileset resource collection even
though the manual said it could be multiple.
+ * <sync> didn't work properly when working on resource collections.
+ Bugzilla Report 51462.
+
Other changes:
--------------
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=1151386&r1=1151385&r2=1151386&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 Wed Jul 27
08:50:44 2011
@@ -487,13 +487,10 @@ public class Sync extends Task {
protected Map scan(Resource[] resources, File toDir) {
assertTrue("No mapper", mapperElement == null);
- Map m = super.scan(resources, toDir);
-
- Iterator iter = m.keySet().iterator();
- while (iter.hasNext()) {
- nonOrphans.add(((Resource) iter.next()).getName());
+ for (int i = 0; i < resources.length; i++) {
+ nonOrphans.add(resources[i].getName());
}
- return m;
+ return super.scan(resources, toDir);
}
/**
Modified: ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml?rev=1151386&r1=1151385&r2=1151386&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/sync-test.xml Wed Jul 27 08:50:44
2011
@@ -151,4 +151,25 @@
</sync>
</target>
+ <target name="testSyncWithResources" depends="setUp"
+
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=51462">
+ <sync todir="${output}">
+ <mappedresources>
+ <fileset dir="${input}"/>
+ <globmapper from="*" to="test/*"/>
+ </mappedresources>
+ </sync>
+ <au:assertFileDoesntExist file="${output}/bar.txt"/>
+ <au:assertFileExists file="${output}/test/a/foo.txt"/>
+
+ <sync todir="${output}">
+ <mappedresources>
+ <fileset dir="${input}"/>
+ <globmapper from="*" to="test/*"/>
+ </mappedresources>
+ </sync>
+ <au:assertFileDoesntExist file="${output}/bar.txt"/>
+ <au:assertFileExists file="${output}/test/a/foo.txt"/>
+ </target>
+
</project>