Class Property

java.lang.Object
All Implemented Interfaces:
Cloneable

public class Property extends Task

Sets a property by name, or set of properties (from file or resource) in the project.

Properties are immutable: whoever sets a property first freezes it for the rest of the build; they are most definitely not variable.

There are seven ways to set properties:

  • By supplying both the name and value attribute.
  • By supplying the name and nested text.
  • By supplying both the name and refid attribute.
  • By setting the file attribute with the filename of the property file to load. This property file has the format as defined by the file used in the class java.util.Properties.
  • By setting the url attribute with the url from which to load the properties. This url must be directed to a file that has the format as defined by the file used in the class java.util.Properties.
  • By setting the resource attribute with the resource name of the property file to load. This property file has the format as defined by the file used in the class java.util.Properties.
  • By setting the environment attribute with a prefix to use. Properties will be defined for every environment variable by prefixing the supplied name and a period to the name of the variable.
  • By setting the runtime attribute with a prefix to use. Properties prefix.availableProcessors, prefix.freeMemory, prefix.totalMemory and prefix.maxMemory will be defined with values that correspond to the corresponding methods of the Runtime class.

Although combinations of these ways are possible, only one should be used at a time. Problems might occur with the order in which properties are set, for instance.

The value part of the properties being set, might contain references to other properties. These references are resolved at the time these properties are set. This also holds for properties loaded from a property file.

Properties are case sensitive.
Since:
Ant 1.1