A few Phing tips

Following on from my last post, here's a few other Phing things that I've found helps me.

Hiding targets from Phing -l

I have a number of dependent targets in my build.xml that I don't want listed when I run phing -l. The easiest way to do this is to add the hidden="true" property to the targets I want to hide:

The output of phing -l now shows just the foo target as I want:

Main target vs subtarget

If you set a description on a target, then it becomes a Main target:

The output is now:

It just looks better and provides additional information as well.

List available targets by default

If you run phing without a target, then the default target runs. If you've forgotten what that is, then this may not be the safest thing to happen. Ideally, the default target should do no harm and I've found it helpful to make the default target display a list of the available targets within the build file.

This is done by adding a hidden "list_targets" target and making it the default:

Essentially, we run phing -l against our current build file and set the passthru property so that the output is displayed. This gives us:

3 thoughts on “A few Phing tips

Comments are closed.