Bug 39009 - scp task: includeEmptyDirs
Summary: scp task: includeEmptyDirs
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.6.5
Hardware: All All
: P2 enhancement with 2 votes (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2006-03-17 08:41 UTC by Markus Barchfeld
Modified: 2009-07-31 06:28 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Barchfeld 2006-03-17 08:41:59 UTC
The Scp task should support includeEmptyDirs as does the copy task.

Index:
C:/Java/ant/ant-core/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
===================================================================
---
C:/Java/ant/ant-core/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
(revision 383811)
+++
C:/Java/ant/ant-core/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java
(working copy)
@@ -42,6 +42,7 @@
 
     private String fromUri;
     private String toUri;
+    private boolean includeEmptyDirs ;
     private List fileSets = null;
     private boolean isFromRemote, isToRemote;
 
@@ -319,6 +320,15 @@
         DirectoryScanner scanner = set.getDirectoryScanner(getProject());
         Directory root = new Directory(scanner.getBasedir());
         String[] files = scanner.getIncludedFiles();
+
+        if (includeEmptyDirs) {
+        	String[] dirs = scanner.getIncludedDirectories();
+        	ArrayList<String> filesAndDirList = new ArrayList<String>() ;
+        	filesAndDirList.addAll(Arrays.asList(dirs)) ;
+        	filesAndDirList.addAll(Arrays.asList(files)) ;
+        	files = filesAndDirList.toArray(new String[] {}) ;
+        }
+
         if (files.length != 0) {
             for (int j = 0; j < files.length; j++) {
                 String[] path = Directory.getPath(files[j]);
@@ -341,4 +351,12 @@
         }
         return root;
     }
+
+    public boolean getIncludeEmptyDirs() {
+		return includeEmptyDirs;
+	}
+
+    public void setIncludeEmptyDirs(boolean includeEmptyDirs) {
+		this.includeEmptyDirs = includeEmptyDirs;
+	}
 }