You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Ma...@dvag.com on 2006/03/10 10:47:54 UTC
scp task: includeEmptyDirs and verbose
Hi all!
We found it useful to implement the option includeEmptyDirs for the scp
task, which is available for the Copy task, too. Because I think that it
could be helpful for others as well you can find the patch below.
Another question concerning the Scp-task: Shouldn't the verbose flag als
influence the log-functionality? I get a lot of log noise even with
verbose = false like the following:
[scp] Sending File: LICENSE : 11558
[scp] File transfer time: 0,06 Average Rate: 183.460,32 B/s
It could be switched off easily by using:
@Override
public void log( String msg ) {
log(msg, this.getVerbose() ? Project.MSG_DEBUG :
Project.MSG_INFO);
}
thanks
Markus
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;
+ }
}