ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From M Damon Hill <hwgwl...@yahoo.com>
Subject Token attribute of the <replace> task
Date Wed, 25 Sep 2002 20:10:23 GMT

Easy question.
Using Ant 1.5.1Alpha, and I am using the <replace> task to update a particular file.
What I want to accomplish is search the given file for a specified token, replace it, and
then use that modified file to update a jar file.
Here is the problem, the given token that I want to replace in the file, can change its value
from build to build (I am working around a bug in IBM XMLConfig that doesn't perserve attributes
when reimporting from a file into an EAR file for deployment onto WebSphere). 
So, here is the target I have:
<target name="replace_cr" depends="init">
     <echo message="Modifying the context root in the ear file"/>
     <unjar src="${targets}/Turbo.ear"
            dest="${targets}">
        <patternset>
            <include name="META-INF/application.xml"/>
        </patternset>
     </unjar>
     <echo message="Extracted the application.xml file"/>
     <replace file="${targets}/META-INF/application.xml"
              token="&gt;context-root&lt;TURBO_Online-*"
              value="&gt;context-root&lt;TUBO_Online-${turbo.id}@${turbo.suffix}gt;/context-root&lt;"/>
     <replace file="${targets}/META-INF/application.xml"
              token="&gt;context-root&lt;TURBO_Admin-*"
              value="&gt;context-root&lt;TURBO_Admin-${turbo.id}@${turbo.suffix}&gt;/context-root&lt;"/>
    <echo message="Replacements completed"/>
    <jar destfile="${targets}/Turbo.ear"
         includesfile="${targets}/META-INF/application.xml"
         update="true"/>
    <echo message="EAR file updated with user specific information!"/>
   </target>

As, you can see, I am trying to match a "pattern" in the token attribute of the replace. However,
obviously, this can't be done. So, does anyone have an EASY way to perform this replace? I
hope so because it appears it should be easliy accomplished.
Thanks in advance.
M Damon Hill



---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message