Ant: Условное копирование

Я хочу перезаписать файл hosts на машине Windows, если пользователь разрешает это:

<input message="Do you want to overwrite the HOSTS file?"
       addproperty="overwrite.hosts" validargs="yes,no" />

<copy tofile="${env.WINDIR}/system32/drivers/etc/hosts.backup">
    <fileset file="${env.WINDIR}/system32/drivers/etc/hosts" />
</copy>

<copy todir="${env.WINDIR}/system32/drivers/etc">
    <fileset file="${trainer.dir}/hosts" />
</copy>

Как мне делать копии, только если пользователь говорит "да"?

РЕДАКТИРОВАТЬ:

Я пробовал это:

    <input message="Do you want to overwrite the HOSTS file?" addproperty="overwrite.hosts" validargs="yes,no" />

    <if>
        <equals arg1="${overwrite.hosts}" arg2="yes" />
        <then>
            <copy tofile="${env.windir}/system32/drivers/etc/hosts.backup">
                <fileset file="${env.windir}/system32/drivers/etc/hosts">
                </fileset>
            </copy>

            <copy todir="${env.windir}/system32/drivers/etc">
                <fileset file="${trainer.dir}/hosts">
                </fileset>
            </copy>
        </then>
    </if>

и получаю такой результат:

C:\trainer\build.xml:16: Problem: failed to create task or type if
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

Я новичок в муравьях ... Что мне нужно делать?

13
задан martin clayton 8 February 2011 в 21:53
поделиться