You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Kothari, Shivani" <sk...@inteqnet.com> on 2008/10/02 11:29:04 UTC
How to replace tokens in to war file?
Hi,
I want to replace tokens inside a war file. How to do that? I am able to
replace tokens in to exploded war folder, but I want to replace tokens
in context.xml inside a war.
Thanks,
Shivani
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to replace context.xml in to already deployed war+application?
Posted by Steve Loughran <st...@apache.org>.
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
How to replace context.xml in to already deployed war+application?
Posted by "Kothari, Shivani" <sk...@inteqnet.com>.
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!!
-----Original Message-----
From: Andy Stevens [mailto:insomniacpenguin@googlemail.com]
Sent: Thursday, October 02, 2008 3:06 PM
To: Ant Users List
Subject: Re: How to replace tokens in to war file?
2008/10/2 Kothari, Shivani <sk...@inteqnet.com>:
> Hi,
> I want to replace tokens inside a war file. How to do that? I am able
to
> replace tokens in to exploded war folder, but I want to replace tokens
> in context.xml inside a war.
Simplest approach I can think of is
Extract file to temporary directory; replace tokens; update war with
modified file.
You could expand the whole war file and repackage it, but since it's
possible to update individual files in a zip/jar/etc. I'd just do
that.
Andy.
--
http://pseudoq.sourceforge.net/ Open source java Sudoku application
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: How to replace tokens in to war file?
Posted by Andy Stevens <in...@googlemail.com>.
2008/10/2 Kothari, Shivani <sk...@inteqnet.com>:
> Hi,
> I want to replace tokens inside a war file. How to do that? I am able to
> replace tokens in to exploded war folder, but I want to replace tokens
> in context.xml inside a war.
Simplest approach I can think of is
Extract file to temporary directory; replace tokens; update war with
modified file.
You could expand the whole war file and repackage it, but since it's
possible to update individual files in a zip/jar/etc. I'd just do
that.
Andy.
--
http://pseudoq.sourceforge.net/ Open source java Sudoku application
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org