AntME logo   AntME title
fill

The 'meMachProp' Task

The meMachProp task is similar to the Ant property task, except that properties can use a prefixing system so that different values are set based on the specific machine on which the Ant build is executed. This can make things easier if developments must span machines in which dependent items are installed in different places, whether due to personal preferences, or due to incompatible path systems (e.g. Windows vs. Linux).

There are three fundamental forms of the meMachProp task:

   <meMachProp  file="path to file"
                 [ prefix="prefix" ] />
                 
   <meMachProp  resource="path to file"
                 [ classpath="class path to use" ]
                 [ prefix="prefix" ] />
                 
   <meMachProp  resource="path to file"
                 [ prefix="prefix" ] >
       <classpath>
           path info
       </classpath>
   </meMachProp>

meMachProp Task Attributes

AttributeValue
file Relative or absolute path to a file to be loaded.
prefix Prefix that will be prepended to each property loaded. If the value does not end with a period, the system will add one automatically.
resource Identifies the name of a resource used with getResourceAsStream to obtain an InputStream from which the data is loaded.
classpath Specifies the classpath used with the resource attribute.

For more information on the behavior of these attributes, see the documentation of the Ant property task.

Property File Format

The meMachProp task accepts files and resources that use the standard Java property file format - a list of keys and values, where the pairs are separated by either an equals sign or a colon:

key1=value1
key2: value2

Standard properties, as shown above, are loaded exactly as with the Ant property task. Where the meMachProp is unique is in its handling of properties that have a specific format.

Every machine has a host name that will be returned by InetAddress.getLocalHost().getHostName(). Properties which have the format machprop.hostname.whatever will only be loaded on the machine whose host name is hostname. Thus, consider the property file which is formatted as follows:

machprop.linuxhost.tempPath=/tmp
machprop.winhost.tempPath=C:\tmp
tempPath=D:\tmp

On a system whose host name is linuxhost, this file would be loaded as if it had contained:

tempPath=/tmp

On a system whose host name is winhost, this file would be loaded as if it had contained:

tempPath=C:\tmp

On any other system, this file would be loaded as if it had contained:

tempPath=D:\tmp

Note that a host's name is automatically converted to all lower case during processing, so the host name in the property should be specified in all lower case.