From 9177c5d9810a2393097bef20d8aee90b9563940e Mon Sep 17 00:00:00 2001 From: Jesse Stockall Date: Tue, 29 Apr 2003 00:07:23 +0000 Subject: [PATCH] Merge file for git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274532 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/Property.xml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 proposal/xdocs/src/org/apache/tools/ant/taskdefs/Property.xml diff --git a/proposal/xdocs/src/org/apache/tools/ant/taskdefs/Property.xml b/proposal/xdocs/src/org/apache/tools/ant/taskdefs/Property.xml new file mode 100644 index 000000000..43b8fd64a --- /dev/null +++ b/proposal/xdocs/src/org/apache/tools/ant/taskdefs/Property.xml @@ -0,0 +1,57 @@ + + + + +

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

+ +

Properties are case sensitive.

+ +

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

+ +

There are five ways to set properties: +

    +
  • By supplying both the name and value attribute.
  • +
  • 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 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.
  • +
+

+

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.

+ +

A list of predefined properties can be found here.

+ +
+ +
+
  <property name="foo.dist" value="dist"/>
+

sets the property foo.dist to the value "dist".

+
  <property file="foo.properties"/>
+

reads a set of properties from a file called "foo.properties".

+
  <property resource="foo.properties"/>
+

reads a set of properties from a resource called "foo.properties".

+

Note that you can reference a global properties file for all of your Ant +builds using the following:

+
  <property file="${user.home}/.ant-global.properties"/>
+

since the "user.home" property is defined by the Java virtual machine +to be your home directory. Where the "user.home" property resolves to in +the file system depends on the operating system version and the JVM implementation. +On Unix based systems, this will map to the user's home directory. On modern Windows +variants, this will most likely resolve to the user's directory in the "Documents +and Settings" folder. Older windows variants such as Windows 98/ME are less +predictable, as are other operating system/JVM combinations.

+ +
+  <property environment="env"/>
+  <echo message="Number of Processors = ${env.NUMBER_OF_PROCESSORS}"/>
+  <echo message="ANT_HOME is set to = ${env.ANT_HOME}"/>
+
+

reads the system environment variables and stores them in properties, prefixed with "env". +Note that this only works on select operating systems. +Two of the values are shown being echoed. +

+ +
+