Browse Source

Make Zip#createEmptyZip be called again when empty zips need to be created

(similar for overrides in superclasses)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278143 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 20 years ago
parent
commit
500030a537
4 changed files with 26 additions and 2 deletions
  1. +3
    -0
      WHATSNEW
  2. +21
    -0
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  3. +1
    -1
      src/testcases/org/apache/tools/ant/taskdefs/JarTest.java
  4. +1
    -1
      src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java

+ 3
- 0
WHATSNEW View File

@@ -362,6 +362,9 @@ Fixed bugs:


* FTP task, getTimeDiff method was returning wrong value. Bugzilla 30595. * 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. * Zip task was not zipping when only empty directories were found.
Bugzilla 30365. Bugzilla 30365.




+ 21
- 0
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -474,6 +474,10 @@ public class Zip extends MatchingTask {
return; return;
} }


if (!zipFile.exists() && state.isWithoutAnyResources()) {
createEmptyZip(zipFile);
return;
}
Resource[][] addThem = state.getResourcesToAdd(); Resource[][] addThem = state.getResourcesToAdd();


if (doUpdate) { if (doUpdate) {
@@ -1384,5 +1388,22 @@ public class Zip extends MatchingTask {
public Resource[][] getResourcesToAdd() { public Resource[][] getResourcesToAdd() {
return resourcesToAdd; 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
- 1
src/testcases/org/apache/tools/ant/taskdefs/JarTest.java View File

@@ -258,7 +258,7 @@ public class JarTest extends BuildFileTest {
} }
} }
public void testManifestOnlyJar() { public void testManifestOnlyJar() {
executeTarget("testManifestOnlyJar");
expectLogContaining("testManifestOnlyJar", "Building MANIFEST-only jar: ");
File manifestFile = getProject().resolveFile(tempDir + "META-INF" + File.separator + "MANIFEST.MF"); File manifestFile = getProject().resolveFile(tempDir + "META-INF" + File.separator + "MANIFEST.MF");
assertTrue(manifestFile.exists()); assertTrue(manifestFile.exists());
} }


+ 1
- 1
src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java View File

@@ -141,7 +141,7 @@ public class ZipTest extends BuildFileTest {
getProject().resolveFile("test3.zip").exists()); getProject().resolveFile("test3.zip").exists());
} }
public void testZipEmptyCreate() { public void testZipEmptyCreate() {
executeTarget("zipEmptyCreate");
expectLogContaining("zipEmptyCreate", "Note: creating empty");
assertTrue("archive should be created", assertTrue("archive should be created",
getProject().resolveFile("test3.zip").exists()); getProject().resolveFile("test3.zip").exists());
} }


Loading…
Cancel
Save