ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: newbie - if-then-else task?
Date Tue, 04 Dec 2001 20:03:28 GMT
--- Russ Fink <> wrote:
> I tried the other way, using depends and targets.  It is REALLY long,
> not succinct,

Well, the way you did it is a bit more roundabout than you really need.
For example (this one assumes the file is required):

  <target name="copyFile" depends="noFile">
    <copy file="${filename}" todir="${dest.dir}"/>

  <target name="chkLocal">
    <available property="filename"
               value="${local.dir}/foo.txt" file="${local.dir}/foo.txt"/>

  <target name="chkSys" depends="chkLocal" unless="filename">
    <available property="filename"
               value="${sys.dir}/foo.txt" file="${sys.dir}/foo.txt"/>

  <target name="noFile" depends="chkSys" unless="filename">
    <echo message=" Error:"/>
    <echo message="   Couldn't find a foo.txt to copy..."/>
    <fail message="Exiting..."/>

> I would have potentially hundreds of files I want to copy,

If where you copy from depends on whether the local directory exists (as
opposed to checking for specific files in that directory), you can change
the <available> to check for the directory -- just add the "type"
attribute, set to "dir" (and adjust your property-setting and <copy>

> Digging in deeper, I strongly suggest supporting in-line Java calls,

You can use <script>, or you can use in-house tasks.



Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message