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.

Reply via email to