https://bz.apache.org/bugzilla/show_bug.cgi?id=59562 Patch by Gilles QUERRETmaster
@@ -136,6 +136,7 @@ Georges-Etienne Legendre | |||||
Gero Vermaas | Gero Vermaas | ||||
Gerrit Riessen | Gerrit Riessen | ||||
Gilbert Rebhan | Gilbert Rebhan | ||||
Gilles Querret | |||||
Gilles Scokart | Gilles Scokart | ||||
Glenn McAllister | Glenn McAllister | ||||
Glenn Twiggs | Glenn Twiggs | ||||
@@ -15,6 +15,10 @@ Fixed bugs: | |||||
* <get>'s quiet attribute was broken, it didn't suppress any messages. | * <get>'s quiet attribute was broken, it didn't suppress any messages. | ||||
Bugzilla Report 59379 | Bugzilla Report 59379 | ||||
* <zip>'s check whether an archive is already up-to-date failed on | |||||
NTFS filesystems and re-created archives more often than necessary. | |||||
Bugzilla Report 59562 | |||||
Other changes: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -568,6 +568,10 @@ | |||||
<first>Gilbert</first> | <first>Gilbert</first> | ||||
<last>Rebhan</last> | <last>Rebhan</last> | ||||
</name> | </name> | ||||
<name> | |||||
<first>Gilles</first> | |||||
<last>Querret</last> | |||||
</name> | |||||
<name> | <name> | ||||
<first>Gilles</first> | <first>Gilles</first> | ||||
<last>Scokart</last> | <last>Scokart</last> | ||||
@@ -283,5 +283,24 @@ | |||||
<zip destFile="${output}/test3.zip" basedir="${output}/ziptest" update="true"/> | <zip destFile="${output}/test3.zip" basedir="${output}/ziptest" update="true"/> | ||||
</target> | </target> | ||||
<target name="testRegexpMapper1"> | |||||
<mkdir dir="${output}/regexp.src"/> | |||||
<touch file="${output}/regexp.src/file1"/> | |||||
<zip destFile="${output}/regexp.zip"> | |||||
<mappedresources> | |||||
<fileset dir="${output}/regexp.src" includes="file1" /> | |||||
<regexpmapper from="^(([a-z][a-z]).*)" to="\2/\1.r" /> | |||||
</mappedresources> | |||||
</zip> | |||||
</target> | |||||
<target name="testRegexpMapper2"> | |||||
<sleep seconds="3" /> | |||||
<zip destFile="${output}/regexp.zip"> | |||||
<mappedresources> | |||||
<fileset dir="${output}/regexp.src" includes="file1" /> | |||||
<regexpmapper from="^(([a-z][a-z]).*)" to="\2/\1.r" /> | |||||
</mappedresources> | |||||
</zip> | |||||
</target> | |||||
</project> | </project> |
@@ -78,7 +78,11 @@ import org.apache.tools.zip.ZipOutputStream.UnicodeExtraFieldPolicy; | |||||
*/ | */ | ||||
public class Zip extends MatchingTask { | public class Zip extends MatchingTask { | ||||
private static final int BUFFER_SIZE = 8 * 1024; | private static final int BUFFER_SIZE = 8 * 1024; | ||||
private static final int ROUNDUP_MILLIS = 1999; // 2 seconds - 1 | |||||
/** | |||||
* The granularity of timestamps inside a ZIP archive. | |||||
*/ | |||||
private static final int ZIP_FILE_TIMESTAMP_GRANULARITY = 2000; | |||||
private static final int ROUNDUP_MILLIS = ZIP_FILE_TIMESTAMP_GRANULARITY - 1; | |||||
// CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
protected File zipFile; | protected File zipFile; | ||||
@@ -1548,7 +1552,8 @@ public class Zip extends MatchingTask { | |||||
final Resource[] rs = selectFileResources(initial); | final Resource[] rs = selectFileResources(initial); | ||||
Resource[] result = | Resource[] result = | ||||
ResourceUtils.selectOutOfDateSources(this, rs, mapper, | ResourceUtils.selectOutOfDateSources(this, rs, mapper, | ||||
getZipScanner()); | |||||
getZipScanner(), | |||||
ZIP_FILE_TIMESTAMP_GRANULARITY); | |||||
if (!doFilesonly) { | if (!doFilesonly) { | ||||
final Union u = new Union(); | final Union u = new Union(); | ||||
u.addAll(Arrays.asList(selectDirectoryResources(initial))); | u.addAll(Arrays.asList(selectDirectoryResources(initial))); | ||||
@@ -297,4 +297,12 @@ public class ZipTest { | |||||
} | } | ||||
} | } | ||||
@Test | |||||
public void testRegexpMapper() throws IOException { | |||||
buildRule.executeTarget("testRegexpMapper1"); | |||||
File testFile = new File(buildRule.getOutputDir(), "regexp.zip"); | |||||
long l = testFile.lastModified(); | |||||
buildRule.executeTarget("testRegexpMapper2"); | |||||
assertEquals(l, testFile.lastModified()); | |||||
} | |||||
} | } |