You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bruce Atherton <br...@callenish.com> on 2001/12/15 02:07:29 UTC
Re: Creating patch jars?
Note that I am redirecting this question to the ant-users mailing list.
At 02:46 PM 12/13/2001 -0500, Russell Gold wrote:
>Is there an ant task for creating patch jars (jars containing only changed
>classes)? Is there some generally accepted way to do this?
I don't know about generally accepted, but here is how I did it for a ZIP file:
<target name="check-for-full-zip">
<available file="${deployzipname}" type="file" property="fullzippresent"/>
</target>
<target name="create-diff-zip" depends="init,check-for-full-zip"
if="fullzippresent" >
<delete quiet="true" includeEmptyDirs="true" >
<fileset dir="${tempdir}" defaultexcludes="no" />
</delete>
<mkdir dir="${tempdir}" />
<record name="${logfilename}" loglevel="warn" />
<unzip src="${deployzipname}" dest="${tempdir}" />
<record name="${logfilename}" loglevel="info" />
<apply executable="/usr/bin/zip" skipemptyfilesets="true" parallel="true"
dest="${tempdir}" dir="${buildpath}" relative="true" >
<arg value="${diffzipname}-${DSTAMP}-${TSTAMP}.zip" />
<fileset dir="${buildpath}" >
<include name="classes/**" />
<include name="ejb/**" />
<include name="static/**" />
<include name="webapp/**" />
</fileset>
<mapper type="identity" />
</apply>
<delete quiet="true" includeEmptyDirs="true" >
<fileset dir="${tempdir}" defaultexcludes="no" />
</delete>
</target>
Note that, due to a difference in the granularity of the timestamps on
files stored in the ZIP (not sure about JARs), rounding error gets you too
many files. To fix it, you have to apply this patch to Ant to make it not
worry about 1 second differences:
Index: src/main/org/apache/tools/ant/util/SourceFileScanner.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/util/SourceFileScanner.java,v
retrieving revision 1.10
diff -u -r1.10 SourceFileScanner.java
--- src/main/org/apache/tools/ant/util/SourceFileScanner.java 2001/11/02
07:56:53 1.10
+++ src/main/org/apache/tools/ant/util/SourceFileScanner.java 2001/12/04
22:21:09
@@ -138,7 +138,7 @@
Project.MSG_VERBOSE);
v.addElement(files[i]);
added = true;
- } else if (src.lastModified() > dest.lastModified()) {
+ } else if ((src.lastModified() - 1000L) >
dest.lastModified()) {
task.log(files[i]+" added as
"+dest.getAbsolutePath()+" is outdated.",
Project.MSG_VERBOSE);
v.addElement(files[i]);
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>