Search code examples
phpxmlbuildphing

How to avoid CopyTask and MoveTask phing build exception on not existing file


I'm creating build file for phing. The problem is that it must move a file which may not exist. If it doesn't I get BuildException "Could not find file ... to copy".

In the Ant there was a property failonerror which ignored the errors of move and copy tasks, but there is no similar property for phing move and copy tasks.

Move phing code:

<move file="no_such_file.txt" tofile="other_path.txt" overwrite="true" />

Is there any built in functionality to catch the errors using phing build? Or maybe it's possible to check on file existence before moving?


Solution

  • I have avoided the problem using such move task:

    <move todir="${dir}" overwrite="true">
        <mapper type="glob" from="no_such_file.txt" to="other_path.txt"/>
        <fileset dir="${dir}" />
    </move>