title: Is there a way to conditionally copy a file using ant?
body: <p>I have the following target:</p>
  
  <pre><code>&lt;target name="promptforchoice"&gt;
  
    &lt;input addproperty="choice"&gt;
       Copy the file?.  [Y, n]
    &lt;/input&gt;
  
      &lt;condition property="copy.file"&gt;
          &lt;or&gt;
              &lt;equals arg1="Y" arg2="${choice}"/&gt;
              &lt;equals arg1="y" arg2="${choice}"/&gt;
          &lt;/or&gt;
      &lt;/condition&gt;
  
  &lt;/target&gt;
  </code></pre>
  
  <p>In another target, I'd like to conditionally copy a file depending on whether or not the copy.file property is set. <strong>Is this possible?</strong> Is there some other way to accomplish it?</p>
  
  <hr>
  
  <h2>My Solution</h2>
  
  <p>Here's what I came up with based on <a href="https://stackoverflow.com/questions/2433975/is-there-a-way-to-conditionally-copy-a-file-using-ant/2434005#2434005">ChrisH's response</a>.</p>
  
  <pre><code>&lt;target name="promptforchoice"&gt;
  
    &lt;input addproperty="choice"&gt;
       Copy the file?.  [Y, n]
    &lt;/input&gt;
  
      &lt;condition property="copy.file"&gt;
          &lt;or&gt;
              &lt;equals arg1="Y" arg2="${choice}"/&gt;
              &lt;equals arg1="y" arg2="${choice}"/&gt;
          &lt;/or&gt;
      &lt;/condition&gt;
  
  &lt;/target&gt;
  
  &lt;target name="copyfile" if="copy.file"&gt;
      &lt;copy file="file1.cfg" tofile="file2.cfg"/&gt;
  &lt;/target&gt;
  
  &lt;target name="build" depends="promptforchoice"&gt;
      &lt;antcall target="copyfile"/&gt;
  
      &lt;!--  Other stuff goes here --&gt;
  
  &lt;/target&gt;
  </code></pre>
  
  <p>Thanks!</p>