ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Douglas Guptill <dgupt...@BlackPearl.thinWEB.com>
Subject RE: Find and replace task
Date Tue, 12 Jun 2001 13:29:07 GMT
In-Reply-To: <000401c0f2f7$23a195d0$bb900cc0@cuiper> 

How about a "refresh", followed by an "editFile", which includes 
a before and after look at the line being editted.  Uses grep.
Only tested on GNU/Linux.

   <antcall target="refreshFile" >  <param name="FILE"  value="${sourceCode}/${ThinAccess_JRAdministrator}"
/>  </antcall>
   <antcall target="editFile" >
                <param name="FileToEdit"    value="${ThinAccess_JRAdministrator}" />
                <param name="FindString"    value="@BuildNumber@" />
                <param name="ReplaceString" value="${BuildNumber}" />
   </antcall>

   <target name="refreshFile" >
       <delete file="${basedir}/../${FILE}" />
       <cvs cvsRoot="/share/cvs" command="checkout" dest="${basedir}/.." package="${FILE}"
 />
   </target>


   <target name="editFile" >
      <echo message="Editing ${FileToEdit}. You should see ${FindString} and ${ReplaceString}."
/>
      <exec executable="grep" dir="." >   <arg value="-n" /> <arg value="${FindString}"
/>    <arg value="${FileToEdit}" />    </exec>
      <replace file="${FileToEdit}"  token="${FindString}" value="${ReplaceString}" />
      <exec executable="grep" dir="." >   <arg value="-n" /> <arg value="${ReplaceString}"
/> <arg value="${FileToEdit}" />    </exec>
   </target>


>> Hello Erik,
>> 
>> thanks. Yes, that would the only possibility I see.
>> 
>> But the program behaves differently while debugging (simple compile in an
>> IDE) and as release (ant).
>> 
>> Tom
>> 
>> |-----Original Message-----
>> |From: Erik Hatcher [mailto:erikhatcher@earthlink.net]
>> |Sent: Monday, June 11, 2001 2:54 PM
>> |To: ant-user@jakarta.apache.org
>> |Subject: Re: Find and replace task
>> |
>> |
>> |What about modifying your build process to have the untouched
>> |source code in
>> |one directory, but copy the code to a temporary directory, run
>> |the replace,
>> |then compile from there.    Would that method work for you?
>> |
>> |    Erik
>> |
>> |
>> |----- Original Message -----
>> |From: "Thomas Singer" <singer@dcs-systeme.de>
>> |To: <ant-user@jakarta.apache.org>
>> |Sent: Sunday, June 10, 2001 11:08 PM
>> |Subject: RE: Find and replace task
>> |
>> |
>> |> Note:
>> |>
>> |> After changing the String's value, I must find it next time, too.
>> |> Without the possibility to specify wildcards in the "token"
>> |it will not
>> |work
>> |> :-(
>> |>
>> |> Tom
>> |>
>> |> |-----Original Message-----
>> |> |From: Thomas Singer [mailto:singer@dcs-systeme.de]
>> |> |Sent: Monday, June 11, 2001 7:56 AM
>> |> |To: ant-user@jakarta.apache.org
>> |> |Subject: RE: Find and replace task
>> |> |
>> |> |
>> |> |Hmm, it seams not to supporting wildcards. Am I right?
>> |> |
>> |> |Tom
>> |> |
>> |> ||-----Original Message-----
>> |> ||From: Erik Hatcher [mailto:erikhatcher@earthlink.net]
>> |> ||Sent: Monday, June 11, 2001 7:37 AM
>> |> ||To: ant-user@jakarta.apache.org
>> |> ||Subject: Re: Find and replace task
>> |> ||
>> |> ||
>> |> ||Have you had a look at the built-in <replace> task?   That
>> |> ||should do the
>> |> ||trick for you.
>> |> ||
>> |> ||    Erik
>> |> ||
>> |> ||
>> |> ||----- Original Message -----
>> |> ||From: "Thomas Singer" <singer@dcs-systeme.de>
>> |> ||To: <ant-user@jakarta.apache.org>
>> |> ||Sent: Sunday, June 10, 2001 10:28 PM
>> |> ||Subject: Find and replace task
>> |> ||
>> |> ||
>> |> ||> Hello,
>> |> ||>
>> |> ||> does anybody knows of an easy-to-use find-and-replace task,
>> |> ||that I could
>> |> ||use
>> |> ||> to solve following problem:
>> |> ||>
>> |> ||> Before compiling I want to modify Java-Source-Code, so the
>> |> ||current date
>> |> ||> (build date) is in there:
>> |> ||>
>> |> ||> ...
>> |> ||>     private final String BUILD_DATE = "2001-06-11";
>> |> ||> ...
>> |> ||>
>> |> ||>
>> |> ||> I know, that I can do that using properties, but I want to
>> |> ||do it that way,
>> |> ||> because it's harder to hack around (it's used for
>> |> ||time-limited stuff).
>> |> ||>
>> |> ||> Regards
>> |> ||> Thomas Singer
>> |> ||>
>> |> ||
>> |> |
>> |>
>> |
>> 
>> 



--
------------------------------------------------------------------
Douglas Guptill                   dguptill@thinweb.com
Quality Assurance Specialist      902-425-2802 x 222
thinWEB Technologies              http://www.thinWEB.com




Mime
View raw message