You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Steve Drach <St...@sun.com> on 2003/03/04 01:17:35 UTC
Jar update problem
I said I had the exact same problem, but I actually misunderstood what
it means to update a jar file using the java.util.zip.* API. In
Java you can't just add an entry to an existing jar (or zip) file,
because there is no API method to do that. You must copy entries
from one jar file to a new one. Here, update means to replace older
entries with new ones, add new ones, and copy older entries that
don't have newer counterparts. The end result is you create a new
jar file that is a duplicate of the old jar file with updated entries.
I was thinking you could just take the old jar file and replace entries in
it if newer entries were found, because I thought that was how unix
zip worked. But thinking about it, you can't do that. In order to do
that, you'd have to invalidate old entries and add the newer counterparts.
Your zipfile would grow and contain lots of garbage. Rewriting the
entire zip file is the only way that makes practical sense.
-----Original Message-----
From: Steve Drach [mailto:Steve.Drach@sun.com]
Sent: Friday, February 28, 2003 3:44 PM
To: user@ant.apache.org
Cc: drach@sun.com
Subject:
I have the exact same problem with "Apache Ant version 1.6alpha compiled
on February 28 2003." This is on Solaris 2.8, so it doesn't seem like
it's been fixed. Is there an open bug report on this?
-----Original Message-----
From: Dominique Devienne <DD...@lgc.com>
Subject: jar update quesiton
Date: Fri, 31 Jan 2003 13:44:13 -0600
Content-Type: text/plain
Well known bug, to be fixed for Ant 1.5.2 and 1.6. Ant BugZilla is
littered with bug entries for the <jar update="true"> problem. Use a
nightly build of CVS were it's supposed to be 99% fixed. --DD
-----Original Message-----
From: Mark Smith [mailto:marksmithurbana@yahoo.com]
Sent: Friday, January 31, 2003 1:21 PM
To: ant-user@jakarta.apache.org
Subject: jar update quesiton
Hi,
I've been looking through this newsgroup and couldn't find someone that
asked this particular question... How do I use the <jar> task to update
a jar file when only a few files in it has been updated?
For example, when doing daily development, I compile my entire codebase,
then jar up a chunk of it for my applet/webstart stuff, then I start my
application, all within ant. So for the <jar> task, I only want files
that have been updated to be updated to the jar. I don't want the
entire jar file to be recreated.
I've played with the update and duplicate options in the <jar> task and
ran in --verbose mode but can't get the effect I'm looking for.. Seems
like no matter what I do, whenever a file is updated, the <jar> task
adds an entry for *every* file, not just the updated files. Also, the
ant documentation does not state what the possible values are for the
"update" tag within the <jar> task.
Any help is greatly appreciated.
Thanks,
Mark
Re: Jar update problem
Posted by Steve Drach <St...@sun.com>.
No, I don't think that'll buy you anything either. You always have to
create a new jar file because there is no method in java.util.zip/jar
that allows you to just add new entries to an existing jar file.
If you do a seperate jar update on each individual file then,
for each file, you'll create a new jar file with that new file and
the set of additional files that were in the old jar file.
Here's an example. If you have a directory like this:
dir
a.class
b.class
c.class
And you create a jar file (J.jar) of that directory, and then modify
b.class and do a jar update with the same fileset, the task will copy
J.jar to (say) J.jar.old, create a new J.jar with dir/b.class in it and
then copy the dir/[ac].class files from J.jar.old to J.jar, and then
delete J.jar.old. This is basically what happens, although it might
not be the correct order.
On Mon, 3 Mar 2003, Mark Smith wrote:
> Well there is one way to accomplish what you were intially thinking.
> That is to scan the fileset that will makeup the jar for files in it
> that are newer than the jar itself. Then manually do a jar update on
> each individual file.
>
> That would work, right?
>
> Mark
>
> On Mon, 2003-03-03 at 19:17, Steve Drach wrote:
> > I said I had the exact same problem, but I actually misunderstood what
> > it means to update a jar file using the java.util.zip.* API. In
> > Java you can't just add an entry to an existing jar (or zip) file,
> > because there is no API method to do that. You must copy entries
> > from one jar file to a new one. Here, update means to replace older
> > entries with new ones, add new ones, and copy older entries that
> > don't have newer counterparts. The end result is you create a new
> > jar file that is a duplicate of the old jar file with updated entries.
> >
> > I was thinking you could just take the old jar file and replace entries in
> > it if newer entries were found, because I thought that was how unix
> > zip worked. But thinking about it, you can't do that. In order to do
> > that, you'd have to invalidate old entries and add the newer counterparts.
> > Your zipfile would grow and contain lots of garbage. Rewriting the
> > entire zip file is the only way that makes practical sense.
> >
> > -----Original Message-----
> > From: Steve Drach [mailto:Steve.Drach@sun.com]
> > Sent: Friday, February 28, 2003 3:44 PM
> > To: user@ant.apache.org
> > Cc: drach@sun.com
> > Subject:
> >
> >
> > I have the exact same problem with "Apache Ant version 1.6alpha compiled
> > on February 28 2003." This is on Solaris 2.8, so it doesn't seem like
> > it's been fixed. Is there an open bug report on this?
> >
> > -----Original Message-----
> > From: Dominique Devienne <DD...@lgc.com>
> > Subject: jar update quesiton
> > Date: Fri, 31 Jan 2003 13:44:13 -0600
> > Content-Type: text/plain
> >
> >
> > Well known bug, to be fixed for Ant 1.5.2 and 1.6. Ant BugZilla is
> > littered with bug entries for the <jar update="true"> problem. Use a
> > nightly build of CVS were it's supposed to be 99% fixed. --DD
> >
> > -----Original Message-----
> > From: Mark Smith [mailto:marksmithurbana@yahoo.com]
> > Sent: Friday, January 31, 2003 1:21 PM
> > To: ant-user@jakarta.apache.org
> > Subject: jar update quesiton
> >
> > Hi,
> >
> > I've been looking through this newsgroup and couldn't find someone that
> > asked this particular question... How do I use the <jar> task to update
> > a jar file when only a few files in it has been updated?
> >
> > For example, when doing daily development, I compile my entire codebase,
> > then jar up a chunk of it for my applet/webstart stuff, then I start my
> > application, all within ant. So for the <jar> task, I only want files
> > that have been updated to be updated to the jar. I don't want the
> > entire jar file to be recreated.
> >
> > I've played with the update and duplicate options in the <jar> task and
> > ran in --verbose mode but can't get the effect I'm looking for.. Seems
> > like no matter what I do, whenever a file is updated, the <jar> task
> > adds an entry for *every* file, not just the updated files. Also, the
> > ant documentation does not state what the possible values are for the
> > "update" tag within the <jar> task.
> >
> > Any help is greatly appreciated.
> >
> > Thanks,
> > Mark
>
Re: Jar update problem
Posted by Mark Smith <ma...@yahoo.com>.
Well there is one way to accomplish what you were intially thinking.
That is to scan the fileset that will makeup the jar for files in it
that are newer than the jar itself. Then manually do a jar update on
each individual file.
That would work, right?
Mark
On Mon, 2003-03-03 at 19:17, Steve Drach wrote:
> I said I had the exact same problem, but I actually misunderstood what
> it means to update a jar file using the java.util.zip.* API. In
> Java you can't just add an entry to an existing jar (or zip) file,
> because there is no API method to do that. You must copy entries
> from one jar file to a new one. Here, update means to replace older
> entries with new ones, add new ones, and copy older entries that
> don't have newer counterparts. The end result is you create a new
> jar file that is a duplicate of the old jar file with updated entries.
>
> I was thinking you could just take the old jar file and replace entries in
> it if newer entries were found, because I thought that was how unix
> zip worked. But thinking about it, you can't do that. In order to do
> that, you'd have to invalidate old entries and add the newer counterparts.
> Your zipfile would grow and contain lots of garbage. Rewriting the
> entire zip file is the only way that makes practical sense.
>
> -----Original Message-----
> From: Steve Drach [mailto:Steve.Drach@sun.com]
> Sent: Friday, February 28, 2003 3:44 PM
> To: user@ant.apache.org
> Cc: drach@sun.com
> Subject:
>
>
> I have the exact same problem with "Apache Ant version 1.6alpha compiled
> on February 28 2003." This is on Solaris 2.8, so it doesn't seem like
> it's been fixed. Is there an open bug report on this?
>
> -----Original Message-----
> From: Dominique Devienne <DD...@lgc.com>
> Subject: jar update quesiton
> Date: Fri, 31 Jan 2003 13:44:13 -0600
> Content-Type: text/plain
>
>
> Well known bug, to be fixed for Ant 1.5.2 and 1.6. Ant BugZilla is
> littered with bug entries for the <jar update="true"> problem. Use a
> nightly build of CVS were it's supposed to be 99% fixed. --DD
>
> -----Original Message-----
> From: Mark Smith [mailto:marksmithurbana@yahoo.com]
> Sent: Friday, January 31, 2003 1:21 PM
> To: ant-user@jakarta.apache.org
> Subject: jar update quesiton
>
> Hi,
>
> I've been looking through this newsgroup and couldn't find someone that
> asked this particular question... How do I use the <jar> task to update
> a jar file when only a few files in it has been updated?
>
> For example, when doing daily development, I compile my entire codebase,
> then jar up a chunk of it for my applet/webstart stuff, then I start my
> application, all within ant. So for the <jar> task, I only want files
> that have been updated to be updated to the jar. I don't want the
> entire jar file to be recreated.
>
> I've played with the update and duplicate options in the <jar> task and
> ran in --verbose mode but can't get the effect I'm looking for.. Seems
> like no matter what I do, whenever a file is updated, the <jar> task
> adds an entry for *every* file, not just the updated files. Also, the
> ant documentation does not state what the possible values are for the
> "update" tag within the <jar> task.
>
> Any help is greatly appreciated.
>
> Thanks,
> Mark