I am fairly new to Java, so I have been using Maven 2.0 exclusively to
build. Not wanting my system config files to clutter CVS, I was trying
to simply move them into the right directories using ant, which is
working fine. But I want to edit the hosts file, and if the host value
I want is not there, to add it.
This seems more like a grep function than something that could be done
easily by ant, but I want this to be platform independent. Is this
something I should do with perl, or can ant do the job?
stevengarcia@yahoo.com - 08 Dec 2005 09:31 GMT
you can do pattern recognition and replacement...that is if your file
contents are
hostname=mercury,venus,%planet%
and you set "planet=earth" as a system property or a property passed in
(or read in) by Ant, then when you copy the file above to a new
location it will replace %planet% with whatever it is set to.
Is that what you are looking for?
Look at the <copy> task and the subtask <filter>
slippymississippi@yahoo.com - 08 Dec 2005 14:20 GMT
Actually, I was thinking of verifying that an IP/hostname pair were
defined in my etc/hosts file, and adding it if I fail to detect.
Does ant have a regexp search function?
Roedy Green - 08 Dec 2005 23:37 GMT
>Does ant have a regexp search function?
it has an exec. Probably easiest to cook up some simple little
utility to do what you want.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
slippymississippi@yahoo.com - 09 Dec 2005 00:48 GMT
> it has an exec. Probably easiest to cook up some simple little
> utility to do what you want.
Gotcha. I noticed that someone had a grep task for ant out there,
though.
Hiran Chaudhuri - 10 Dec 2005 14:03 GMT
>>Does ant have a regexp search function?
> it has an exec. Probably easiest to cook up some simple little
> utility to do what you want.
Ant has been developed to have platform neutral make scripts. If you call
something like grep your script won't be portable as easily.
Hiran