Есть ли способ условно скопировать файл с помощью муравья? - PullRequest
8 голосов
/ 12 марта 2010

У меня есть следующая цель:

<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>

В другой цели я бы хотел условно скопировать файл в зависимости от того, установлено или нет свойство copy.file. Возможно ли это? Есть ли другой способ сделать это?


Мое решение

Вот что я придумал, основываясь на ответе ChrisH .

<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>

Спасибо!

1 Ответ

6 голосов
/ 12 марта 2010

Вы, вероятно, хотите что-то вроде:

<target name="mycopy" if="copy.file">
   <!-- do copy -->
</target>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...