PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 19 ■ AUTOMATED BUILD WITH PHING

$ phing runsecond
Buildfile: /home/bob/working/megaquiz/build.xml


megaquiz > runfirst:


megaquiz > runsecond:


BUILD FINISHED


Total time: 0.2671 seconds


By passing in a target name, I cause the default attribute to be ignored. The target matching my
argument is invoked instead (as well as the target on which it depends). This is useful for invoking
specialized tasks, such as cleaning up a build directory or running post-install scripts.
The target element also supports an optional description attribute, to which you can assign a brief
description of the target’s purpose:


<?xml version="1.0"?>



<project name="megaquiz"
default="main"
description="A quiz engine">
<target name="runfirst"
description="The first target" />
<target name="runsecond"
depends="runfirst"
description="The second target" />
<target name="main"
depends="runsecond"
description="The main target" />



Adding a description to your targets makes no difference to the normal build process. If the user
runs Phing with a -projecthelp flag, however, the descriptions will be used to summarize the project:


$ phing -projecthelp
Buildfile: /home/bob/working/megaquiz/build.xml
A quiz engine
Default target:


main The main target


Main targets:


main The main target
runfirst The first target
runsecond The second target


Notice that I added the description attribute to the project element too.
Free download pdf