Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

replace files in a jar...

Thread view: 
David N. Welton - 05 Nov 2005 19:57 GMT
I can't seem to find a way to force this:

     [jar] org/hecl/BasicMathCmd.class omitted as
org/hecl/BasicMathCmd.class is up to date.

     [jar] org/hecl/EqualsCmd.class omitted as org/hecl/EqualsCmd.class
is up to date.

     [jar] org/hecl/IntThing.class omitted as org/hecl/IntThing.class
is up to date.

I want these to always be replaced.  Is there a way to get ant to do
this?  So far I have:

   <jar destfile="Hecl.jar" basedir="build/float" update="true"/>

I don't see any options in the documentation that seem like they'll do
what I want... any ideas on how to get around this problem?

Thanks!
Signature

David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/

zero - 05 Nov 2005 20:43 GMT
"David N. Welton" <davidw@dedasys.com> wrote in news:436d00dd$0$6007
$4fafbaef@reader4.news.tin.it:

> I can't seem to find a way to force this:
>
[quoted text clipped - 16 lines]
>
> Thanks!

I don't know about ant, but if I remember correctly you can't replace files
inside a jar without recreating the complete jar.  This is because of the
format of jars.
Rhino - 06 Nov 2005 17:33 GMT
> "David N. Welton" <davidw@dedasys.com> wrote in news:436d00dd$0$6007
> $4fafbaef@reader4.news.tin.it:
[quoted text clipped - 23 lines]
> inside a jar without recreating the complete jar.  This is because of the
> format of jars.

I've always believed that there is no way to delete or replace an entry from
a zip or a jar. As far as I knew, you have to create a new jar that has the
desired files in it.

However, according to the Ant user manual,
http://ant.apache.org/manual/index.html, the Jar and Zip tasks have an
'update' flag. Apparently:

---
The update parameter controls what happens if the ZIP file already exists.
When set to yes, the ZIP file is updated with the files specified. (New
files are added; old files are replaced with the new versions.) When set to
no (the default) the ZIP file is overwritten if any of the files that would
be added to the archive are newer than the entries inside the archive.

[The update parameter is supposed to behave the same for the Jar task as for
the Zip task.]
---

Unfortunately, the examples in the articles for the Zip and Jar tasks are
not very helpful. Perhaps the original poster should ask on the ant user
mailing list? That is a fairly active list and some very experienced Ant
users hang out there to help. This page - http://ant.apache.org/mail.html -
gives instructions on joining the mailing list. A search of the Ant archives
for the 'user' list might also turn up useful information. You can access
that archive at the same page and search the archive for keywords.

Or maybe someone will come along who has used the update flag in a Jar task
who can explain what the original poster is doing wrong.

The only possibility that occurs to me is based on this sentence from both
the Jar and Zip tasks:

---
Please note that ZIP files store file modification times with a granularity
of two seconds. If a file is less than two seconds newer than the entry in
the archive, Ant will not consider it newer.
---

Is it possible that the new versions of the files that are to be replaced in
the jar have two seconds or less difference in their timestamps?

Rhino


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.