Browse Source

another sync preserveintarget edge case

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@727751 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
cd22c5c17b
2 changed files with 35 additions and 0 deletions
  1. +5
    -0
      src/main/org/apache/tools/ant/taskdefs/Sync.java
  2. +30
    -0
      src/tests/antunit/taskdefs/sync-test.xml

+ 5
- 0
src/main/org/apache/tools/ant/taskdefs/Sync.java View File

@@ -135,6 +135,11 @@ public class Sync extends Task {

int removedDirCount = 0;
if (!myCopy.getIncludeEmptyDirs()) {
if (syncTarget != null
&& syncTarget.getPreserveEmptyDirs() != Boolean.TRUE) {
preservedDirectories.clear();
}

removedDirCount =
removeEmptyDirectories(toDir, false, preservedDirectories);
} else { // must be syncTarget.preserveEmptydirs == FALSE


+ 30
- 0
src/tests/antunit/taskdefs/sync-test.xml View File

@@ -87,4 +87,34 @@
<au:assertFileDoesntExist file="${output}/b/c"/>
</target>

<target name="testPreserveEmptyAndIncludeEmptyFalse" depends="setUp">

<sync todir="${output}" includeEmptyDirs="false">
<fileset dir="${input}"/>
<preserveintarget preserveEmptyDirs="false">
<include name="**/b/**"/>
</preserveintarget>
</sync>

<au:assertFileDoesntExist file="${output}/a/bar.txt"/>
<au:assertFileExists file="${output}/a/foo.txt"/>
<au:assertFileExists file="${output}/b/baz.txt"/>
<au:assertFileDoesntExist file="${output}/b/c"/>
</target>

<target name="testPreserveEmptyAndIncludeEmptyTrue" depends="setUp">

<sync todir="${output}" includeEmptyDirs="true">
<fileset dir="${input}"/>
<preserveintarget preserveEmptyDirs="true">
<include name="**/b/**"/>
</preserveintarget>
</sync>

<au:assertFileDoesntExist file="${output}/a/bar.txt"/>
<au:assertFileExists file="${output}/a/foo.txt"/>
<au:assertFileExists file="${output}/b/baz.txt"/>
<au:assertFileExists file="${output}/b/c"/>
</target>

</project>

Loading…
Cancel
Save