You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/09/28 21:11:56 UTC

svn commit: r292262 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java

Author: mbenson
Date: Wed Sep 28 12:11:52 2005
New Revision: 292262

URL: http://svn.apache.org/viewcvs?rev=292262&view=rev
Log:
Handle filesets added via add(ResourceCollection)
by sending back to addFileset().  remove tabs.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java?rev=292262&r1=292261&r2=292262&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java Wed Sep 28 12:11:52 2005
@@ -103,7 +103,7 @@
      * @param list the FileList to add.
      */
     public void addFilelist(FileList list) {
-	add(list);
+        add(list);
     }
 
     /**
@@ -112,9 +112,11 @@
      * @since Ant 1.7
      */
     public void add(ResourceCollection rc) {
-	if (rc instanceof FileSet)
-	    throw new BuildException("Huh?");
-	resources.add(rc);
+        if (rc instanceof FileSet) {
+            addFileset((FileSet) rc);
+        } else {
+            resources.add(rc);
+        }
     }
 
     /**
@@ -415,67 +417,67 @@
                     baseDirs.removeAllElements();
                 }
             }
-	
-	    Iterator iter = resources.iterator();
-	    while (iter.hasNext()) {
-		Resource res = (Resource) iter.next();
-
-		if (!res.isExists() && ignoreMissing) {
-		    continue;
-		}
-
-		File base = null;
-		String name = res.getName();
-		if (res instanceof FileResource) {
-		    FileResource fr = (FileResource) res;
-		    base = fr.getBaseDir();
-		    if (base == null) {
-			name = fr.getFile().getAbsolutePath();
-		    }
-		}
-
-		if (restrict(new String[] {name}, base).length == 0) {
-		    continue;
-		}
-
-		if ((!res.isDirectory() || !res.isExists())
-		    && !FileDirBoth.DIR.equals(type)) {
-		    totalFiles++;
-		} else if (res.isDirectory() && !FileDirBoth.FILE.equals(type)) {
-		    totalDirs++;
-		} else {
-		    continue;
-		}
 
-		baseDirs.add(base);
-		fileNames.add(name);
+            Iterator iter = resources.iterator();
+            while (iter.hasNext()) {
+                Resource res = (Resource) iter.next();
+
+                if (!res.isExists() && ignoreMissing) {
+                    continue;
+                }
+
+                File base = null;
+                String name = res.getName();
+                if (res instanceof FileResource) {
+                    FileResource fr = (FileResource) res;
+                    base = fr.getBaseDir();
+                    if (base == null) {
+                        name = fr.getFile().getAbsolutePath();
+                    }
+                }
+
+                if (restrict(new String[] {name}, base).length == 0) {
+                    continue;
+                }
+
+                if ((!res.isDirectory() || !res.isExists())
+                    && !FileDirBoth.DIR.equals(type)) {
+                    totalFiles++;
+                } else if (res.isDirectory() && !FileDirBoth.FILE.equals(type)) {
+                    totalDirs++;
+                } else {
+                    continue;
+                }
+
+                baseDirs.add(base);
+                fileNames.add(name);
 
                 if (!parallel) {
-		    String[] command = getCommandline(name, base);
-		    log(Commandline.describeCommand(command),
-			Project.MSG_VERBOSE);
-		    exe.setCommandline(command);
-
-		    if (redirectorElement != null) {
-			setupRedirector();
-			redirectorElement.configure(redirector, name);
-		    }
-		    if (redirectorElement != null || haveExecuted) {
-			// need to reset the stream handler to restart
-			// reading of pipes;
-			// go ahead and do it always w/ nested redirectors
-			exe.setStreamHandler(redirector.createHandler());
-		    }
-		    runExecute(exe);
-		    haveExecuted = true;
-		    fileNames.removeAllElements();
-		    baseDirs.removeAllElements();
-		}
+                    String[] command = getCommandline(name, base);
+                    log(Commandline.describeCommand(command),
+                    Project.MSG_VERBOSE);
+                    exe.setCommandline(command);
+
+                    if (redirectorElement != null) {
+                        setupRedirector();
+                        redirectorElement.configure(redirector, name);
+                    }
+                    if (redirectorElement != null || haveExecuted) {
+                        // need to reset the stream handler to restart
+                        // reading of pipes;
+                        // go ahead and do it always w/ nested redirectors
+                        exe.setStreamHandler(redirector.createHandler());
+                    }
+                    runExecute(exe);
+                    haveExecuted = true;
+                    fileNames.removeAllElements();
+                    baseDirs.removeAllElements();
+                }
             }
             if (parallel && (fileNames.size() > 0 || !skipEmpty)) {
                 runParallel(exe, fileNames, baseDirs);
                 haveExecuted = true;
-	    }
+            }
             if (haveExecuted) {
                 log("Applied " + cmdl.getExecutable() + " to "
                     + totalFiles + " file"
@@ -719,8 +721,8 @@
      * for the type attribute.
      */
     public static class FileDirBoth extends EnumeratedAttribute {
-	public static final String FILE = "file";
-	public static final String DIR = "dir";
+        public static final String FILE = "file";
+        public static final String DIR = "dir";
         /**
          * @see EnumeratedAttribute#getValues
          */



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r292262 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 28 Sep 2005, Matt Benson <gu...@yahoo.com> wrote:

> I thought so, but what about programmatic usage? 

If you use add(FileSet) you don't expect it to get treated different
from the other resource collections.  Only in the addFileset case, at
least that's what I think.

<apply> has some strange effects as legacy when you use fileset or
dirset (which you'd need to address as well BTW).  Things like
switching type to "dir" if you use a dirset even if you explicitly set
ot to file or the flag that says "run the command even if the fileset
is empty".

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r292262 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java

Posted by Matt Benson <gu...@yahoo.com>.

--- Stefan Bodewig <bo...@apache.org> wrote:

> On Wed, 28 Sep 2005, <mb...@apache.org> wrote:
> 
> > Handle filesets added via add(ResourceCollection)
> > by sending back to addFileset()
> 
> No, that never happens.  The exception was a debug
> step I forgot to remove.

I thought so, but what about programmatic usage? 
That's what I was attempting to address.  :)

-Matt

> 
> >  remove tabs.
> 
> when I saw the commit mails I realized that I hadn't
> disabled tabs on
> my company notebook's XEmacs.  Sorry.
> 
> Stefan
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe@ant.apache.org
> For additional commands, e-mail:
> dev-help@ant.apache.org
> 
> 



		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r292262 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 28 Sep 2005, <mb...@apache.org> wrote:

> Handle filesets added via add(ResourceCollection)
> by sending back to addFileset()

No, that never happens.  The exception was a debug step I forgot to remove.

>  remove tabs.

when I saw the commit mails I realized that I hadn't disabled tabs on
my company notebook's XEmacs.  Sorry.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org