| creating files | creating files 2007-06-11 - By Jukka Uusisalo
<property file="test.properties"/>
<target name="do_replace"> <copy tofile="result_file.txt" file="template.txt"/> <replace file="result_file.txt" token="_Replace_This_" value="${foo}"/> </target>
In test.properties file i have foo=bar
template.txt contains Hello World by _Replace_This_
After execution target do_replace result_file.txt contains Hello World by bar
- Jukka -
> -----Original Message----- > From: arijit [mailto:ghosh.arijit@(protected)] > Sent: 11. kesakuuta 2007 14:27 > To: user@(protected) > Subject: RE: creating files > > > > even if I load the property file, I can't see how I can read > the key value > pair from the property which is loaded and use it to replace > the token with > the read value... any sample code ? > > arijit wrote: > > > > thanks for that warning about <echo>.. didn't think about > that... i might > > have a Template BATCH file available to me and only use <replace> to > > replace the token... This wil of course, mean that I will have to > > manually make modifications to the template.. > > > > > > Rebhan, Gilbert wrote: > >> > >> > >> Hi, > >> > >> > >> -----Original Message----- > >> From: arijit [mailto:ghosh.arijit@(protected)] > >> Sent: Monday, June 11, 2007 12:01 PM > >> To: user@(protected) > >> Subject: RE: creating files > >> > >> /* > >> great.. I can now create batch files using <echo file.... > > and also use > >> <echo message.... file.... > to add contents to the file. > >> */ > >> > >> also <echo>foobar</foobar> possible, message attribut not needed. > >> > >> But beware with echo, every blank and line feed gets written as you > >> write > >> it in <echo>, means if you don't want blanks on the left side, you > >> should write > >> starting at position 0 > >> > >> /* > >> is it possible to read data from some property file and > then use it to > >> generate the batch file ? In other words, batch file > generated will have > >> some information which is read from the property file and > added to the > >> batch > >> file at runtime. > >> */ > >> > >> you may load a whole file as property or load a file that has > >> propertyformat > >> (key=value) ,see manual <property>, <loadfile>, <loadproperties> > >> > >> > >> For more complicated file processing (with regular expressions ...) > >> you should use <script> and a language running in BSF > JRuby, Groovy > >> or Javascript recommended. > >> > >> Regards, Gilbert > >> > >> > --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@(protected) > >> For additional commands, e-mail: user-help@(protected) > >> > >> > >> > > > > > > -- > View this message in context: http://www.nabble.com/creating-files-tf3900318.html#a11058929 Sent from the Ant - Users mailing list archive at Nabble.com.
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@(protected) For additional commands, e-mail: user-help@(protected)
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@(protected) For additional commands, e-mail: user-help@(protected)
|
|
 |