Aside from assigning and using your own properties Phing also comes with a set of built in properties that can be used to find out all sorts of information regarding the system that Phing is run on.
As an example, let's say you wanted to found out the operating system that phing is being run on. In this case you would use the variable host.os, which on a Windows XP system would print out WINNT.
There are a lot of different properties available, so I have included the table from the phing website at the bottom of this post as a reference. However, there is one special variable called env that needs further explanation. The env variable references any environment variables that have been set. For example, if you set an environment variable using the following shell command (on UNIX based systems only).
You can now reference this in your build.xml file by using the following.
Here is a table of the built in properties available.
|application.startdir||Current work directory|
|env.*||Environment variables, extracted from $_SERVER.|
|host.arch||System architecture, i.e. i586. Not available on Windows machines.|
|host.domain||DNS domain name, i.e. php.net. Not available on Windows machines.|
|host.fstype||The type of the filesystem. Possible values are UNIX, WINNT and WIN32|
|host.name||Operating System hostname as returned by posix_uname(). Not available on Windows machines.|
|host.os||Operating System description as set in PHP_OS variable (see PHP Manual).|
|host.os.release||Operating version release, i.e. 2.2.10. Not available on Windows machines.|
|host.os.version||Operating system version, i.e. #4 Tue Jul 20 17:01:36 MEST 1999. Not available on Windows machines.|
|line.separator||Character(s) that signal the end of a line, "\n" for Linux, "\r\n" for Windows system, "\r" for Macintosh.|
|os.name||Operating System description as set in PHP_OS variable.|
|phing.file||Full path to current buildfile.|
|phing.home||Phing installation directory, not set in PEAR installations.|
|phing.version||Current Phing version.|
|phing.project.name||Name of the currently processed project.|
|php.classpath||The value of the environment variable PHP_CLASSPATH.|
|php.version||Version of the PHP interpreter. Same as PHP constant PHP_VERSION (see PHP Manual).|
|project.basedir||The current project basedir.|
|user.home||Value of the environment variable HOME.|
This list can also be found on the Phing website.
I have found that even though some of variables specifically say "not available on Windows" most of them will produce some sort of output, even on Windows machines. Here is a test build.xml file that you can use to see what the different variables print out on your system.
<!-- build xml -->
<project name="myProject" default="main">
This file misses out the env property as this is a custom property.
Automated Build With Phing