ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fenlason, Josh" <jfenla...@ptc.com>
Subject Replace Question
Date Thu, 14 Dec 2006 16:43:32 GMT
I want to add a line to a file, but only if the file doesn't already
contain that line.  I can add the line fine, but I can't figure out how
to do it conditionally.  Is this possible?   Here's what I have so far.
Any suggestions would be greatly appreciated.  Thanks in advance.
<target name="test">
     <!-- this replace works, but it adds the line every time -->
     <replace dir="bin" file="bin/start.bat">
         <replacetoken><![CDATA[start]]></replacetoken>
         <replacevalue><![CDATA[set bar=foo
start]]></replacevalue>
      </replace>

      <!-- this doesn't replace anything no matter if start.bat contains
set bar=foo or not -->
      <replace dir="bin" includes="bin/start.bat">
         <not><contains text="set bar=foo" casesensitive="yes"/></not>
         <replacetoken><![CDATA[start]]></replacetoken>
         <replacevalue><![CDATA[set bar=foo
start]]></replacevalue>
      </replace>

   </target>
,
Josh.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message