(similar for overrides in superclasses) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278143 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -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. | ||||
| @@ -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; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -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()); | ||||
| } | } | ||||
| @@ -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()); | ||||
| } | } | ||||