You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@locus.apache.org on 2000/09/06 14:03:29 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs ExecuteOn.java

bodewig     00/09/06 05:03:21

  Modified:    docs     index.html
               src/main/org/apache/tools/ant/taskdefs ExecuteOn.java
  Log:
  Added a type attribute to <execon> and <chmod>. It can take the values
  "file", "dir" and "both" and deteremines, whether the task should work
  on plain files only (the default), directories only or both.
  Suggested by:	Peter Donald <do...@mad.scientist.com>,
                  Kitching Simon <Si...@orange.ch>
  
  Revision  Changes    Path
  1.91      +20 -4     jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- index.html	2000/09/05 14:15:37	1.90
  +++ index.html	2000/09/06 12:03:07	1.91
  @@ -1059,6 +1059,14 @@
         <code>chmod</code> command. Defaults to true.</td>
       <td valign="top" align="center">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">type</td>
  +    <td valign="top">One of <em>file</em>, <em>dir</em> or
  +      <em>both</em>. If set to <em>file</em>, only the permissions of
  +      plain files are going to be changed. If set to <em>dir</em>, only
  +      the directories are considered.</td>
  +    <td align="center" valign="top">No, default is <em>file</em></td>
  +  </tr>
   </table>
   <h3>Examples</h3>
   <blockquote>
  @@ -1548,10 +1556,10 @@
   <p>Executes a system command. When the <i>os</i> attribute is specified, then
   the command is only executed when Ant is run on one of the specified operating
   systems.</p>
  -<p>The files of a number of <a href="#fileset">FileSet</a>s are passed
  -as arguments to the system command. At least one nested
  -<code>&lt;fileset&gt;</code> or <code>&lt;filesetref&gt;</code> is
  -required.</p>
  +<p>The files and/or directories of a number of <a
  +href="#fileset">FileSet</a>s are passed as arguments to the system
  +command. At least one nested <code>&lt;fileset&gt;</code> or
  +<code>&lt;filesetref&gt;</code> is required.</p>
   <h3>Parameters</h3>
   <table border="1" cellpadding="2" cellspacing="0">
     <tr>
  @@ -1600,6 +1608,14 @@
         arguments. Defaults to true. If false, command will be executed
         once for every file.</td>
       <td align="center" valign="top">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">type</td>
  +    <td valign="top">One of <em>file</em>, <em>dir</em> or
  +      <em>both</em>. If set to <em>file</em>, only the names of plain
  +      files will be sent to the command. If set to <em>dir</em>, only
  +      the names of directories are considered.</td>
  +    <td align="center" valign="top">No, default is <em>file</em></td>
     </tr>
   </table>
   <h3>Parameters specified as nested elements</h3>
  
  
  
  1.7       +30 -3     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java
  
  Index: ExecuteOn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ExecuteOn.java	2000/08/03 11:25:11	1.6
  +++ ExecuteOn.java	2000/09/06 12:03:16	1.7
  @@ -71,6 +71,7 @@
   
       protected Vector filesets = new Vector();
       private boolean parallel = false;
  +    protected String type = "file";
   
       /**
        * Adds a set of files (nested fileset attribute).
  @@ -93,6 +94,13 @@
           this.parallel = parallel;
       }
   
  +    /**
  +     * Shall the command work only on files, directories or both?
  +     */
  +    public void setType(FileDirBoth type) {
  +        this.type = type.getValue();
  +    }
  +
       protected void checkConfiguration() {
           super.checkConfiguration();
           if (filesets.size() == 0) {
  @@ -122,10 +130,19 @@
                   }
                   
                   DirectoryScanner ds = fs.getDirectoryScanner(project);
  -                String[] s = ds.getIncludedFiles();
  -                for (int j=0; j<s.length; j++) {
  -                    v.addElement(new File(fs.getDir(), s[j]).getAbsolutePath());
  +                if (!"dir".equals(type)) {
  +                    String[] s = ds.getIncludedFiles();
  +                    for (int j=0; j<s.length; j++) {
  +                        v.addElement(new File(fs.getDir(), s[j]).getAbsolutePath());
  +                    }
                   }
  +
  +                if (!"file".equals(type)) {
  +                    String[] s = ds.getIncludedDirectories();
  +                    for (int j=0; j<s.length; j++) {
  +                        v.addElement(new File(fs.getDir(), s[j]).getAbsolutePath());
  +                    }
  +                }
               }
   
               String[] s = new String[v.size()];
  @@ -170,6 +187,16 @@
           } finally {
               // close the output file if required
               logFlush();
  +        }
  +    }
  +
  +    /**
  +     * Enumerated attribute with the values "file", "dir" and "both"
  +     * for the type attribute.  
  +     */
  +    public static class FileDirBoth extends EnumeratedAttribute {
  +        public String[] getValues() {
  +            return new String[] {"file", "dir", "both"};
           }
       }