ant question

  • Thread starter slippymississippi
  • Start date
S

slippymississippi

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?
 
S

stevengarcia

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>
 
S

slippymississippi

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?
 
S

slippymississippi

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.
 
H

Hiran Chaudhuri

Roedy Green said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top