ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <>
Subject Re: easier way to conditionally copy file? / write my own task?
Date Fri, 12 Oct 2001 19:49:13 GMT
As a general rule-of-thumb, when I find myself creating targets that are
essentially doing the same thing, I probably want to start thinking about
creating a target to <antcall> to. For example, in your case (btw: I've
set the dirs into properties, but you don't really have to do that -- I
just find it easier to deal with):

  <property name="tomcat.fms.classes" value="foodir"/>
  <property name="" value="foodir"/>
  <property name="was.fms.test.home" value="foodir"/>
  <property name="tomcat.classes"
  <property name="dev.home"
  <property name="test.home"
  <property name="sprint.fms" value="src/com/sprint/fms"/>
  <property name="" value="src/com/sprint/com"/>

  <target name="copyFiles">
    <antcall target="doCopy">
      <param name="dir" value="${sprint.fms}"/>
      <param name="todir" value="${tomcat.classes}"/>
    <antcall target="doCopy">
      <param name="dir" value="${sprint.fms}"/>
      <param name="todir" value="${dev.home}"/>
    <antcall target="doCopy">
      <param name="dir" value="${}"/>
      <param name="todir" value="${test.home}"/>

  <target name="doCopy" depends="checkFile" unless="constantsAvailable">
    <copy file="${dir}/"

  <target name="checkFile">
    <condition property="constantsAvailable">
      <available file="${todir}/"/>

If you need to add additional files to check for, just add an <antcall>
for them. If it turns out the filenames won't always be the same, add a
(eg.) "file" parameter to pass as well (ie., changing things like
file="${dir}/" to file="${dir}/${file}").



Do You Yahoo!?
Make a great connection at Yahoo! Personals.

View raw message