ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: How to replace context.xml in to already deployed war+application?
Date Thu, 02 Oct 2008 14:43:50 GMT
Kothari, Shivani wrote:
> Hi,
> I want to replace context.xml in already deployed application .war file
> and in application folder in webapps. How can this be achieved in ant.
> I have written below code - but this currpting my existing deployed
> application.
> 
> 
> <unwar src="application.war" dest="${dirs.working}/temp"/>
>         <delete file="var/lib/tomcat55/webapps/application.war"/>
>         <delete dir="var/lib/tomcat55/webapps/application"/>
>         <copy
> file="var/lib/tomcat55/webapps/application/META-INF/context.xml"
> todir="${dirs.working}/temp/META-INF/"/>
> 
>         
>        <!-- Creating the Configured application web archive for
> Deployment-->
>       <war destfile=var/lib/tomcat55/webapps/application.war"
> webxml="${dirs.working}/temp/WEB-INF/web.xml" update="yes">
>            <fileset dir="${dirs.working}/temp"/>
>       </war>		
> 
> 
> If anybody can help on this..
> 
> Thanks in advance!!

> Andy.

This is a pretty dangerous way of working with WAR files, though I 
understand why you need to generate new WARs for every target. Indeed, 
this is one reason why I don't like war files. Remember that <war> is 
just <jar> with a few hard-coded options; you can use <jar> or <zip> to

bundle up a directory tree.

1. just <unzip> and then <zip> after the <copy>, but remember to use 
overwrite="true" in the copy to force overwrite the unzipped XML file 
with the custom one, even if the unzipped XML file is newer.

2. Dont do this on the live machine; do it before it gets there

Looking at your code

-you delete a dir
          <delete dir="var/lib/tomcat55/webapps/application"/>

-then copy a file from under that directory
          <copy
  file="var/lib/tomcat55/webapps/application/META-INF/context.xml"
  todir="${dirs.working}/temp/META-INF/"/>

That is unlikely to work well. You should keep that context.xml 
somewhere safe and copy it in using overwrite="true" in <copy>

-- 
Steve Loughran                  http://www.1060.org/blogxter/publish/5
Author: Ant in Action           http://antbook.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message