ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/types FileSet.java PatternSet.java
Date Thu, 01 Feb 2001 17:14:08 GMT
bodewig     01/02/01 09:14:07

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/types FileSet.java
                        PatternSet.java
  Log:
  perform property expansion on the patterns read from files specified
  as includesfile or excludesfile attributes.
  
  Suggested by:	Jason Rosenberg <jason@squaretrade.com>
  
  Revision  Changes    Path
  1.73      +3 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.72
  retrieving revision 1.73
  diff -u -r1.72 -r1.73
  --- WHATSNEW	2001/02/01 15:28:16	1.72
  +++ WHATSNEW	2001/02/01 17:14:03	1.73
  @@ -64,6 +64,9 @@
   * Added classpath attribute and nested classpath element to <property>
     to make the resource attribute more powerful.
   
  +* ${} property expansion will now be performed on the patterns read
  +  from files specified as includesfile or excludesfile attributes.
  +
   Fixed bugs:
   -----------
   
  
  
  
  1.13      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java
  
  Index: FileSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/FileSet.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- FileSet.java	2001/01/30 10:56:07	1.12
  +++ FileSet.java	2001/02/01 17:14:05	1.13
  @@ -93,7 +93,7 @@
        * this element if you make it a reference.</p> 
        */
       public void setRefid(Reference r) throws BuildException {
  -        if (dir != null || defaultPatterns.countPatterns() > 0) {
  +        if (dir != null || defaultPatterns.hasPatterns()) {
               throw tooManyAttributes();
           }
           if (!additionalPatterns.isEmpty()) {
  
  
  
  1.5       +28 -7     jakarta-ant/src/main/org/apache/tools/ant/types/PatternSet.java
  
  Index: PatternSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/PatternSet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PatternSet.java	2001/01/03 14:18:46	1.4
  +++ PatternSet.java	2001/02/01 17:14:06	1.5
  @@ -55,6 +55,7 @@
   package org.apache.tools.ant.types;
   
   import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.ProjectHelper;
   import org.apache.tools.ant.BuildException;
   
   import java.io.*;
  @@ -79,6 +80,9 @@
       private Vector includeList = new Vector();
       private Vector excludeList = new Vector();
       
  +    private File incl = null;
  +    private File excl = null;
  +
       /**
        * inner class to hold a name on list.  "If" and "Unless" attributes
        * may be used to invalidate the entry based on the existence of a 
  @@ -214,9 +218,8 @@
            if (!incl.exists()) {
                throw new BuildException("Includesfile "+incl.getAbsolutePath()
                                         +" not found.");
  -         } else {
  -             readPatterns(incl, includeList);
            }
  +         this.incl = incl;
        }
   
       /**
  @@ -231,16 +234,15 @@
            if (!excl.exists()) {
                throw new BuildException("Excludesfile "+excl.getAbsolutePath()
                                         +" not found.");
  -         } else {
  -             readPatterns(excl, excludeList);
            }
  +         this.excl = excl;
        }
       
       /**
        *  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)
  +    private void readPatterns(File patternfile, Vector patternlist, Project p)
           throws BuildException {
           
           try {
  @@ -253,6 +255,8 @@
               String line = patternReader.readLine();
               while (line != null) {
                   if (line.length() > 0) {
  +                    line = ProjectHelper.replaceProperties(p, line,
  +                                                           p.getProperties());
                       addPatternToList(patternlist).setName(line);
                   }
                   line = patternReader.readLine();
  @@ -294,6 +298,7 @@
           if (isReference()) {
               return getRef(p).getIncludePatterns(p);
           } else {
  +            readFiles(p);
               return makeArray(includeList, p);
           }
       }
  @@ -305,6 +310,7 @@
           if (isReference()) {
               return getRef(p).getExcludePatterns(p);
           } else {
  +            readFiles(p);
               return makeArray(excludeList, p);
           }
       }
  @@ -312,8 +318,9 @@
       /**
        * helper for FileSet.
        */
  -    int countPatterns() {
  -        return includeList.size() + excludeList.size();
  +    boolean hasPatterns() {
  +        return incl != null || excl != null
  +            || includeList.size() > 0 || excludeList.size() > 0;
       }
   
       /**
  @@ -356,4 +363,18 @@
           return result;
       }
           
  +    /**
  +     * Read includefile ot excludefile if not already done so.
  +     */
  +    private void readFiles(Project p) {
  +        if (incl != null) {
  +            readPatterns(incl, includeList, p);
  +            incl = null;
  +        }
  +        if (excl != null) {
  +            readPatterns(excl, excludeList, p);
  +            excl = null;
  +        }
  +    }
  +
   }
  
  
  

Mime
View raw message