Let me direct your attention to this thread on ant-user.

http://marc.theaimsgroup.com/?t=100258096800004&w=2&r=1

Specifically to Pete's comment...
=====
Or perhaps more simply

  <move tofile="my/jndi/dir/jndir.jar">
    <fileset dir="my/jndi/dir">
      <include name="jndi*.jar"/>
    </fileset>
  </move>
=====

In the above case, Pete has suggested the user use
Fileset to resolve pattern mappings issue instead of
going for regexps.  The only problem the use of this
approach is that if jndi*.jar results in multiple files
in the fileset, we won't know how to move them all to
a single file.

However, if the pattern jndi*.jar in my/jndi/dir 
returns only one file, a valid copy/move should be
performed (logical user expectation).

But, as it is now, the Copy and Move tasks will not
let the user use toFile and FileSets even if there is
no (src)file attribute specified and the fileset
contains just one file.

Here is a patch that looks into the fileset before
dismissing it outright.  Once this patch is in place
Pete's suggestion in the user group will work so long
as the pattern doesn't result in multiple files.

Thanks,
Magesh
 
Index: copy.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/manual/CoreTasks/copy.html,v
retrieving revision 1.2
diff -w -u -r1.2 copy.html
--- copy.html   2001/02/13 12:31:50     1.2
+++ copy.html   2001/10/10 19:55:29
@@ -39,7 +39,9 @@
     <td valign="top">The file to copy to.</td>
     <td valign="top" align="center" rowspan="2">With the <var>file</var> 
attribute, 
     either <var>tofile</var> or <var>todir</var> can be used.  With nested 
filesets, 
-    only <var>todir</var> is allowed.</td>
+    if the fileset size is greater than 1 or if the only entry in the fileset 
is a
+    directory or if the file attribute is already specified, only
+    <var>todir</var> is allowed</td>
   </tr>
   <tr>
     <td valign="top">todir</td>




Index: Copy.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
retrieving revision 1.20
diff -w -u -r1.20 Copy.java
--- Copy.java   2001/08/18 14:59:39     1.20
+++ Copy.java   2001/10/10 19:58:34
@@ -74,6 +74,7 @@
  * @author Glenn McAllister <a href="mailto:[EMAIL PROTECTED]">[EMAIL 
PROTECTED]</a>
  * @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
  * @author <A href="[EMAIL PROTECTED]">Michael McCallum</A>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Magesh Umasankar</a>
  */
 public class Copy extends Task {
     protected File file = null;     // the source file 
@@ -287,7 +288,27 @@
         }
            
         if (destFile != null && filesets.size() > 0) {
-            throw new BuildException("Cannot concatenate multple files into a 
single file.");
+            if (filesets.size() > 1) {
+                throw new BuildException(
+                    "Cannot concatenate multiple files into a single file.");
+            } else {
+                FileSet fs = (FileSet) filesets.elementAt(0);
+                DirectoryScanner ds = fs.getDirectoryScanner(project);
+                String[] srcFiles = ds.getIncludedFiles();
+
+                if (srcFiles.length > 0) {
+                    if (file == null) {
+                        file = new File(srcFiles[0]);
+                        filesets.removeElementAt(0);
+                    } else {
+                        throw new BuildException(
+                            "Cannot concatenate multiple files into a single 
file.");
+                    }
+                } else {
+                    throw new BuildException(
+                        "Cannot perform operation from directory to file.");
+                }
+            }
         }
 
         if (destFile != null) {

Reply via email to