tags:

views:

90

answers:

1

I have the following target:

<target name="promptforchoice">

  <input addproperty="choice">
     Copy the file?.  [Y, n]
  </input>

    <condition property="copy.file">
        <or>
            <equals arg1="Y" arg2="${choice}"/>
            <equals arg1="y" arg2="${choice}"/>
        </or>
    </condition>

</target>

In another target, I'd like to conditionally copy a file depending on whether or not the copy.file property is set. Is this possible? Is there some other way to accomplish it?


My Solution

Here's what I came up with based on ChrisH's response.

<target name="promptforchoice">

  <input addproperty="choice">
     Copy the file?.  [Y, n]
  </input>

    <condition property="copy.file">
        <or>
            <equals arg1="Y" arg2="${choice}"/>
            <equals arg1="y" arg2="${choice}"/>
        </or>
    </condition>

</target>

<target name="copyfile" if="copy.file">
    <copy file="file1.cfg" tofile="file2.cfg"/>
</target>

<target name="build" depends="promptforchoice">
    <antcall target="copyfile"/>

    <!--  Other stuff goes here -->

</target>

Thanks!

+5  A: 

You probably want something like:

<target name="mycopy" if="copy.file">
   <!-- do copy -->
</target>
ChrisH