bodewig     2003/05/02 07:44:54

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/taskdefs Zip.java
  Log:
  Don't update archives because it lacks directory entries when we are
  not going to add directory entries either.
  
  PR: 19449
  
  Revision  Changes    Path
  1.408     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.407
  retrieving revision 1.408
  diff -u -r1.407 -r1.408
  --- WHATSNEW  2 May 2003 08:18:36 -0000       1.407
  +++ WHATSNEW  2 May 2003 14:44:53 -0000       1.408
  @@ -112,6 +112,9 @@
   * file names that include spaces need to be quoted inside the @argfile
     argument using forked <javac> and JDK 1.4.  Bugzilla Report 10499.
   
  +* Setting filesonly to true in <zip> and related tasks would cause the
  +  archives to be always recreated.  Bugzilla Report 19449.
  +
   Other changes:
   --------------
   * Six new Clearcase tasks added.
  
  
  
  1.105     +32 -0     ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
  
  Index: Zip.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- Zip.java  18 Apr 2003 22:02:58 -0000      1.104
  +++ Zip.java  2 May 2003 14:44:53 -0000       1.105
  @@ -812,6 +812,10 @@
                                                        initialResources[i],
                                                        myMapper,
                                                        getZipScanner());
  +            if (doFilesonly) {
  +                newerResources[i] = selectFileResources(newerResources[i]);
  +            }
  +            
               needsUpdate = needsUpdate || (newerResources[i].length > 0);
   
               if (needsUpdate && !doUpdate) {
  @@ -1114,6 +1118,34 @@
               }
           }
           return true;
  +    }
  +
  +    /**
  +     * Drops all non-file resources from the given array.
  +     *
  +     * @since Ant 1.6
  +     */
  +    protected Resource[] selectFileResources(Resource[] orig) {
  +        if (orig.length == 0) {
  +            return orig;
  +        }
  +        
  +        Vector v = new Vector(orig.length);
  +        for (int i = 0; i < orig.length; i++) {
  +            if (!orig[i].isDirectory()) {
  +                v.addElement(orig[i]);
  +            } else {
  +                log("Ignoring directory " + orig[i].getName() 
  +                    + " as only files will be added.", Project.MSG_VERBOSE);
  +            }
  +        }
  +
  +        if (v.size() != orig.length) {
  +            Resource[] r = new Resource[v.size()];
  +            v.copyInto(r);
  +            return r;
  +        }
  +        return orig;
       }
   
       /**
  
  
  

Reply via email to