ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: newbie - if-then-else task?
Date Tue, 04 Dec 2001 20:03:28 GMT
--- Russ Fink <russfink@hotmail.com> 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>

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

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

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

> 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>
accordingly).

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

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

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message