ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs MatchingTask.java
Date Mon, 26 Jun 2000 12:46:57 GMT
bodewig     00/06/26 05:46:56

  Modified:    docs     index.html
               src/main/org/apache/tools/ant/taskdefs MatchingTask.java
  Log:
  Add includesfile and excludesfile attributes to MatchingTask.
  
  This adds the ability to keep the patterns for inclusion/exclusion
  separate from the buildfile - increasing the readability in some
  difficult cases.
  
  The code is based on the patch submitted by Aaron on 2000/05/24 with
  some modifications.
  
  Submitted by:	Aaron Knauf <AaronK@geniesystems.com>
  
  Revision  Changes    Path
  1.29      +176 -25   jakarta-ant/docs/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/index.html,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- index.html	2000/06/23 16:46:45	1.28
  +++ index.html	2000/06/26 12:46:51	1.29
  @@ -375,6 +375,10 @@
   </ul>
   <p>When both inclusion and exclusion are used, only files/directories that match
   the include patterns, and don't match the exclude patterns are used.</p>
  +<p>Patterns can be specified inside the buildfile via task attributes or
  +nested elements and via external files. Each line of the external file
  +is taken as pattern that is added to the list of include or exclude 
  +patterns.</p>
   <h3>Patterns</h3>
   <p>As described earlier, patterns are used for the inclusion and exclusion.
   These patterns look very much like the patterns used in DOS and UNIX:</p>
  @@ -617,9 +621,9 @@
   <h3>Description</h3>
   <p>Copies a directory tree from the source to the destination.</p>
   <p>It is possible to refine the set of files that are being copied. This can be
  -done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included by using patterns. The <i>exclude</i> attribute is used to specify
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
   the files you want to have excluded. This is also done with patterns. And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -661,12 +665,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">comma separated list of patterns of files that must be
         excluded. No files (except default excludes) are excluded when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -806,9 +822,9 @@
   <p>Deletes either a single file or
   all files in a specified directory and its sub-directories.</p>
   <p>It is possible to refine the set of files that are being deleted. This can be
  -done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included in the deletion process by using patterns. The <i>exclude</i>
attribute is used to specify
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included in the deletion process by using patterns. The <i>exclude</i>
or <i>excludesfile</i> attribute is used to specify
   the files you want to have excluded from the deletion process. This is also done with patterns.
And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -839,12 +855,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">Comma separated list of patterns of files that must be
         excluded from the deletion list. No files (except default excludes) are excluded
when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">Indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -1012,7 +1040,16 @@
   <h2><a name="fixcrlf">FixCRLF</a></h2>
   <h3>Description</h3>
   <p>Adjusts a text file to local.</p>
  -<p>The <i>basedir</i> attribute is the reference directory from where
to jar.</p>
  +<p>It is possible to refine the set of files that are being adjusted. This can be
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
  +the files you want to have excluded. This is also done with patterns. And
  +finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
  +want to use default exclusions or not. See the section on <a
  +href="#directorybasedtasks">directory based tasks</a>, on how the
  +inclusion/exclusion of files works, and how to write patterns. The patterns are
  +relative to the <i>src</i> directory.</p>
   <h3>Parameters</h3>
   <table border="1" cellpadding="2" cellspacing="0">
     <tr>
  @@ -1038,12 +1075,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">comma separated list of patterns of files that must be
         excluded. No files (except default excludes) are excluded when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -1246,9 +1295,9 @@
   <p>Jars a set of files.</p>
   <p>The <i>basedir</i> attribute is the reference directory from where
to jar.</p>
   <p>It is possible to refine the set of files that are being jarred. This can be
  -done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included by using patterns. The <i>exclude</i> attribute is used to specify
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
   the files you want to have excluded. This is also done with patterns. And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -1309,12 +1358,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">comma separated list of patterns of files that must be
         excluded. No files (except default excludes) are excluded when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -1427,9 +1488,9 @@
   <p>The directory structure of the source tree should follow the package
   hierarchy.</p>
   <p>It is possible to refine the set of files that are being compiled/copied.
  -This can be done with the <i>includes</i>, <i>excludes</i> and
<i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included by using patterns. The <i>exclude</i> attribute is used to specify
  +This can be done with the <i>includes</i>, <i>includesfile</i>,
<i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
   the files you want to have excluded. This is also done with patterns. And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -1470,12 +1531,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">comma separated list of patterns of files that must be
         excluded. No files (except default excludes) are excluded when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -2165,9 +2238,9 @@
   <p>Creates a tar archive.</p>
   <p>The <i>basedir</i> attribute is the reference directory from where
to tar.</p>
   <p>It is possible to refine the set of files that are being tarred. This can be
  -done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included by using patterns. The <i>exclude</i> attribute is used to specify
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
   the files you want to have excluded. This is also done with patterns. And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -2211,12 +2284,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">comma separated list of patterns of files that must be
         excluded. No files (except default excludes) are excluded when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -2294,9 +2379,9 @@
   <p>This is useful for building views of XML based documentation,
   or in generating code.</p>
   <p>It is possible to refine the set of files that are being copied. This can be
  -done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included by using patterns. The <i>exclude</i> attribute is used to specify
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
   the files you want to have excluded. This is also done with patterns. And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -2340,6 +2425,36 @@
   class path</td>
       <td align="center" valign="top">No</td>
     </tr>
  +  <tr>
  +    <td valign="top">includes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      included. All files are included when omitted.</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">excludes</td>
  +    <td valign="top">comma separated list of patterns of files that must be
  +      excluded. No files (except default excludes) are excluded when omitted.</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">defaultexcludes</td>
  +    <td valign="top">indicates whether default excludes should be used or not
  +      (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
   </table>
   <h3>Examples</h3>
   <blockquote>
  @@ -2385,9 +2500,9 @@
   <p>Creates a zipfile.</p>
   <p>The <i>basedir</i> attribute is the reference directory from where
to zip.</p>
   <p>It is possible to refine the set of files that are being zipped. This can be
  -done with the <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i>
  -attributes. With the <i>includes</i> attribute you specify the files you want
to
  -have included by using patterns. The <i>exclude</i> attribute is used to specify
  +done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>,
<i>excludesfile</i> and <i>defaultexcludes</i>
  +attributes. With the <i>includes</i> or <i>includesfile</i> attribute
you specify the files you want to
  +have included by using patterns. The <i>exclude</i> or <i>excludesfile</i>
attribute is used to specify
   the files you want to have excluded. This is also done with patterns. And
   finally with the <i>defaultexcludes</i> attribute, you can specify whether
you
   want to use default exclusions or not. See the section on <a
  @@ -2448,12 +2563,24 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">excludes</td>
       <td valign="top">comma separated list of patterns of files that must be
         excluded. No files (except default excludes) are excluded when omitted.</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">defaultexcludes</td>
       <td valign="top">indicates whether default excludes should be used or not
         (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when
omitted.</td>
  @@ -2590,10 +2717,10 @@
   <p>The directory structure of the source tree should follow the package
   hierarchy.</p>
   <p>It is possible to refine the set of files that are being compiled/copied.
  -This can be done with the <i>includes</i>, <i>excludes</i> and
  -<i>defaultexcludes</i> attributes. With the <i>includes</i> attribute
you 
  +This can be done with the <i>includes</i>, <i>includesfile</i>,
<i>excludes</i>, <i>excludesfile</i> and
  +<i>defaultexcludes</i> attributes. With the <i>includes</i> or
<i>includesfile</i> attribute you 
   specify the files you want to have included by using patterns. The 
  -<i>exclude</i> attribute is used to specify the files you want to have 
  +<i>exclude</i> or <i>excludesfile</i> attribute is used to specify
the files you want to have 
   excluded.  This is also done with patterns.  And finally with the 
   <i>defaultexcludes</i> attribute, you can specify whether you
   want to use default exclusions or not. See the section on <a
  @@ -2681,6 +2808,12 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">explicit</td>
       <td valign="top">Whether variables must be declared explicitly
         before use</td>
  @@ -2699,6 +2832,12 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">java</td>
       <td valign="top">Whether the generated java code is produced</td>
       <td valign="top" align="center">No</td>
  @@ -2855,6 +2994,12 @@
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  +    <td valign="top">excludesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an exclude pattern</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
       <td valign="top">fromExtention</td>
       <td valign="top">The string that files must end in to be renamed</td>
       <td valign="top" align="center">Yes</td>
  @@ -2863,6 +3008,12 @@
       <td valign="top">includes</td>
       <td valign="top">comma separated list of patterns of files that must be
         included. All files are included when omitted.</td>
  +    <td valign="top" align="center">No</td>
  +  </tr>
  +  <tr>
  +    <td valign="top">includesfile</td>
  +    <td valign="top">the name of a file. Each line of this file is
  +      taken to be an include pattern</td>
       <td valign="top" align="center">No</td>
     </tr>
     <tr>
  
  
  
  1.6       +74 -6     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
  
  Index: MatchingTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MatchingTask.java	2000/02/29 02:59:57	1.5
  +++ MatchingTask.java	2000/06/26 12:46:55	1.6
  @@ -107,18 +107,14 @@
        * add a name entry on the include list
        */
       public NameEntry createInclude() {
  -        NameEntry result = new NameEntry();
  -        includeList.addElement(result);
  -        return result;
  +        return addPatternToList(includeList);
       }
       
       /**
        * add a name entry on the exclude list
        */
       public NameEntry createExclude() {
  -        NameEntry result = new NameEntry();
  -        excludeList.addElement(result);
  -        return result;
  +        return addPatternToList(excludeList);
       }
   
       /**
  @@ -239,4 +235,76 @@
           ds.scan();
           return ds;
       }
  +
  +    /**
  +     * add a name entry to the given list
  +     */
  +    private NameEntry addPatternToList(Vector list) {
  +        NameEntry result = new NameEntry();
  +        list.addElement(result);
  +        return result;
  +    }
  +
  +    /**
  +     *  Reads path matching patterns from a file and adds them to the
  +     *  includes or excludes list (as appropriate).  
  +     */
  +    private void readPatterns(File patternfile, Vector patternlist) {
  +
  +        try {
  +            // Get a FileReader
  +            BufferedReader patternReader = 
  +                new BufferedReader(new FileReader(patternfile)); 
  +        
  +            // Create one NameEntry in the appropriate pattern list for each 
  +            // line in the file.
  +            String line = patternReader.readLine();
  +            while (line != null) {
  +                if (line.length() > 0) {
  +                    addPatternToList(patternlist).setName(line);
  +                }
  +                line = patternReader.readLine();
  +            }
  +        } catch(IOException ioe)  {
  +            project.log("An error occured while reading from pattern file: " 
  +                        + patternfile, Project.MSG_ERR); 
  +        }
  +    }
  +
  +    /**
  +     * Sets the name of the file containing the includes patterns.
  +     *
  +     * @param includesfile A string containing the filename to fetch
  +     * the include patterns from.  
  +     */
  +     public void setIncludesfile(String includesfile) {
  +         if (includesfile != null && includesfile.length() > 0) {
  +             File incl = project.resolveFile(includesfile);
  +             if (!incl.exists()) {
  +                 project.log("Includesfile "+includesfile+" not found.", 
  +                             Project.MSG_ERR); 
  +             } else {
  +                 readPatterns(incl, includeList);
  +             }
  +         }
  +     }
  +
  +    /**
  +     * Sets the name of the file containing the includes patterns.
  +     *
  +     * @param excludesfile A string containing the filename to fetch
  +     * the include patterns from.  
  +     */
  +     public void setExcludesfile(String excludesfile) {
  +         if (excludesfile != null && excludesfile.length() > 0) {
  +             File excl = project.resolveFile(excludesfile);
  +             if (!excl.exists()) {
  +                 project.log("Excludesfile "+excludesfile+" not found.", 
  +                             Project.MSG_ERR); 
  +             } else {
  +                 readPatterns(excl, excludeList);
  +             }
  +         }
  +     }
  +
   }
  
  
  

Mime
View raw message