antoine     2005/04/18 13:09:08

  Modified:    src/main/org/apache/tools/ant/taskdefs Zip.java
               src/testcases/org/apache/tools/ant/taskdefs ZipTest.java
                        JarTest.java
               .        WHATSNEW
  Log:
  Make Zip#createEmptyZip be called again when empty zips need to be created
  (similar for overrides in superclasses)
  
  Revision  Changes    Path
  1.140     +21 -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.139
  retrieving revision 1.140
  diff -u -r1.139 -r1.140
  --- Zip.java  11 Mar 2005 08:41:41 -0000      1.139
  +++ Zip.java  18 Apr 2005 20:09:08 -0000      1.140
  @@ -474,6 +474,10 @@
                   return;
               }
   
  +            if (!zipFile.exists() && state.isWithoutAnyResources()) {
  +                createEmptyZip(zipFile);
  +                return;
  +            }
               Resource[][] addThem = state.getResourcesToAdd();
   
               if (doUpdate) {
  @@ -1384,5 +1388,22 @@
           public Resource[][] getResourcesToAdd() {
               return resourcesToAdd;
           }
  +        /**
  +         * find out if there are absolutely no resources to add
  +         * @return true if there are no resources to add
  +         */
  +        public boolean isWithoutAnyResources() {
  +            if (resourcesToAdd == null)  {
  +                return true;
  +            }
  +            for (int counter = 0; counter < resourcesToAdd.length; 
counter++) {
  +                if (resourcesToAdd[counter] != null) {
  +                    if (resourcesToAdd[counter].length > 0) {
  +                        return false;
  +                    }
  +                }
  +            }
  +            return true;
  +        }
       }
   }
  
  
  
  1.27      +1 -1      
ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
  
  Index: ZipTest.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ZipTest.java      18 Feb 2005 12:19:37 -0000      1.26
  +++ ZipTest.java      18 Apr 2005 20:09:08 -0000      1.27
  @@ -141,7 +141,7 @@
                      getProject().resolveFile("test3.zip").exists());
       }
       public void testZipEmptyCreate() {
  -        executeTarget("zipEmptyCreate");
  +        expectLogContaining("zipEmptyCreate", "Note: creating empty");
           assertTrue("archive should be created",
                      getProject().resolveFile("test3.zip").exists());
       }
  
  
  
  1.33      +1 -1      
ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java
  
  Index: JarTest.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- JarTest.java      6 Jan 2005 12:05:04 -0000       1.32
  +++ JarTest.java      18 Apr 2005 20:09:08 -0000      1.33
  @@ -258,7 +258,7 @@
           }
       }
       public void testManifestOnlyJar() {
  -        executeTarget("testManifestOnlyJar");
  +        expectLogContaining("testManifestOnlyJar", "Building MANIFEST-only 
jar: ");
           File manifestFile = getProject().resolveFile(tempDir + "META-INF" + 
File.separator + "MANIFEST.MF");
           assertTrue(manifestFile.exists());
       }
  
  
  
  1.806     +3 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.805
  retrieving revision 1.806
  diff -u -r1.805 -r1.806
  --- WHATSNEW  15 Apr 2005 20:25:36 -0000      1.805
  +++ WHATSNEW  18 Apr 2005 20:09:08 -0000      1.806
  @@ -362,6 +362,9 @@
   
   * FTP task, getTimeDiff method was returning wrong value. Bugzilla 30595.
   
  +* make sure that Zip and its derivates call the createEmptyZip method when
  + there are no resources to zip/jar/...
  +
   * Zip task was not zipping when only empty directories were found.
     Bugzilla 30365.
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to