Skip to main content

Adding a jar library to an existing war file inside an ant script

2 replies [Last post]
nano22
Offline
Joined: 2008-04-18
Points: 0

Hi ,

I have have the following where by i want to add the following lib.jar to an existing assembled proj.war file.

in my ant script I unzip the proj.war file
<unzip src="${home.dir}/build.war dest="${home.dir}/uncompressed_buildwar"/>
<copyfile="${home.dir}/dept/lib.jar"
todir="${home.dir}/uncompressed_buildwar" />
Now I would like to package up the war file with the new lib.jar i.e build.war .
Any ideas how i can achieve this ?

tried to use
<war destfile="${home.dir}/build.war"
basedir="${home.dir}/uncompressed_buildwar">
</war>
but this doesn't work ?!?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
sauvage
Offline
Joined: 2004-03-04
Points: 0

you should copy your lib to right place ie in WEB-INF/lib subdirectory:
<copyfile="${home.dir}/dept/lib.jar" todir="${home.dir}/uncompressed_buildwar/WEB-INF/lib" />
And notice "doesn't work" is not an error message, so you should provide it.

dabrigo
Offline
Joined: 2004-05-13
Points: 0

Didn't test it, but you can simply use a zip task with update attribute:

or if you need to put it in a subdirectory: