Raphael Stolt has another post dealing with the Phing (PHP-based) build tool. This time he talks about making ad hoc tasks inside of your build scripts.
Sometimes there are build scenarios where you'll badly need a functionality, like adding a MD5 checksum file to a given project, that isn't provided neither by the available Phing core nor the optional tasks. [...] The following post will try to outline how to define and use these inline tasks, by sketching an ad hoc task that enables the build orchestra to clone Git repositories from GitHub during a hypothetical workbench setup.
He creates an example task - running a "clone" command via github - complete with the code for both sides of the feature; the PHP code to create the task and how to use it in your build file.