You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2018/04/26 16:14:43 UTC

[1/2] ant git commit: add properties created from Runtime's methods

Repository: ant
Updated Branches:
  refs/heads/master 22a05c5ba -> 6a9d70120


add properties created from Runtime's methods

inspired by https://stackoverflow.com/questions/1170337/how-can-i-get-the-number-of-availableprocessors-in-ant


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/5e99fc2c
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/5e99fc2c
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/5e99fc2c

Branch: refs/heads/master
Commit: 5e99fc2c1ad0930b8f46ead6fdb5fc63b430827f
Parents: f72406d
Author: Stefan Bodewig <bo...@apache.org>
Authored: Thu Apr 26 13:56:09 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Thu Apr 26 13:56:09 2018 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |  5 ++
 manual/Tasks/property.html                      | 23 ++++++
 src/etc/testcases/taskdefs/property.xml         |  4 ++
 .../org/apache/tools/ant/taskdefs/Property.java | 74 ++++++++++++++++++--
 .../apache/tools/ant/taskdefs/PropertyTest.java | 13 ++++
 5 files changed, 115 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/5e99fc2c/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 3041bc5..a87bd81 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -36,6 +36,11 @@ Other changes:
    finishing threads might fail.
    Bugzilla Report 62148
 
+ * <property> has a new attribute runtime which can be used to set
+   properties with values taken as snapshots from the
+   availableProcessors, freeMemory, maxMemory and totalMemory methods
+   of the Java Runtime class.
+
 Changes from Ant 1.9.10 TO Ant 1.9.11
 =====================================
 

http://git-wip-us.apache.org/repos/asf/ant/blob/5e99fc2c/manual/Tasks/property.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/property.html b/manual/Tasks/property.html
index 7dc90a7..e8e57bb 100644
--- a/manual/Tasks/property.html
+++ b/manual/Tasks/property.html
@@ -49,6 +49,13 @@ resource) in the project.  Properties are case sensitive.</p>
   <li>By setting the <i>environment</i> 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.</li>
+  <li>By setting the <i>runtime</i> attribute with a prefix to use.
+    Properties <code>prefix.availableProcessors</code>,
+    <code>prefix.freeMemory</code>, <code>prefix.totalMemory</code>
+    and <code>prefix.maxMemory</code> will be defined with values that
+    correspond to the corresponding methods of
+    the <a href="https://docs.oracle.com/javase/10/docs/api/java/lang/Runtime.html">Runtime</a>
+    class.</li>
 </ul>
 <p>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
@@ -127,6 +134,22 @@ to end with <tt>.xml</tt>.</p>
     rather than "env.PATH".</td>
   </tr>
   <tr>
+    <td valign="top">runtime</td>
+    <td valign="top">the prefix to use when retrieving Runtime properties. Thus
+    if you specify runtime=&quot;myrt&quot; you will be able to access
+    runtime values corresponding to methods in
+    the <a href="https://docs.oracle.com/javase/10/docs/api/java/lang/Runtime.html">Runtime</a>
+    class via property names &quot;myrt.availableProcessors&quot;,
+    &quot;myrt.maxMemory&quot;, &quot;myrt.totalMemory&quot; or
+    &quot;myrt.freeMemory&quot;. Note that if you supply a property name with a final
+    &quot;.&quot; it will not be doubled; i.e. runtime=&quot;myrt.&quot; will still
+    allow access of prpperties through &quot;myrt.maxMemory&quot;.<br>
+    Note also that the property values are snapshots taken at the point in time
+    when the <code>property</code> has been executed.
+    <em>Since Ant 1.9.12</em>
+    </td>
+  </tr>
+  <tr>
     <td valign="top">classpath</td>
     <td valign="top">the classpath to use when looking up a resource.</td>
     <td align="center" valign="top">No</td>

http://git-wip-us.apache.org/repos/asf/ant/blob/5e99fc2c/src/etc/testcases/taskdefs/property.xml
----------------------------------------------------------------------
diff --git a/src/etc/testcases/taskdefs/property.xml b/src/etc/testcases/taskdefs/property.xml
index 87cda8b..2e0c835 100644
--- a/src/etc/testcases/taskdefs/property.xml
+++ b/src/etc/testcases/taskdefs/property.xml
@@ -89,4 +89,8 @@
   </target>    
   <target name="testXmlProperty" depends="testXmlProperty.internal"/>  
 
+  <target name="testRuntime">
+    <property runtime="testruntime"/>
+  </target>
+
 </project>

http://git-wip-us.apache.org/repos/asf/ant/blob/5e99fc2c/src/main/org/apache/tools/ant/taskdefs/Property.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java
index 64a6376..a6b51a2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Property.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Property.java
@@ -59,6 +59,12 @@ import org.apache.tools.ant.util.FileUtils;
  *   <li>By setting the <i>environment</i> 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.</li>
+ *   <li>By setting the <i>runtime</i> attribute with a prefix to use.
+ *     Properties <code>prefix.availableProcessors</code>,
+ *     <code>prefix.freeMemory</code>, <code>prefix.totalMemory</code>
+ *     and <code>prefix.maxMemory</code> will be defined with values
+ *     that correspond to the corresponding methods of the {@link
+ *     Runtime} class.</li>
  * </ul>
  * <p>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
@@ -86,6 +92,7 @@ public class Property extends Task {
     protected String env;
     protected Reference ref;
     protected String prefix;
+    private String runtime;
     private Project fallback;
     private Object untypedValue;
     private boolean valueAttributeUsed = false;
@@ -388,6 +395,42 @@ public class Property extends Task {
     }
 
     /**
+     * Prefix to use when retrieving Runtime properties.
+     *
+     * <p>Properties <code>prefix.availableProcessors</code>,
+     * <code>prefix.freeMemory</code>, <code>prefix.totalMemory</code>
+     * and <code>prefix.maxMemory</code> will be defined with values
+     * that correspond to the corresponding methods of the {@link
+     * Runtime} class.</p>
+     *
+     * <p>Note that if you supply a prefix name with a final
+     * &quot;.&quot; it will not be doubled. ie
+     * runtime=&quot;myrt.&quot; will still allow access of property
+     * through &quot;myrt.availableProcessors&quot; and
+     * &quot;myrt.freeMemory&quot;.</p>
+     *
+     * <p>The property values are snapshots taken at the point in time
+     * when the <code>property</code> has been executed.</p>
+     *
+     * @param prefix prefix
+     *
+     * @ant.attribute group="noname"
+     * @since Ant 1.9.12
+     */
+    public void setRuntime(String prefix) {
+        this.runtime = prefix;
+    }
+
+    /**
+     * Get the runtime attribute.
+     * @return the runtime attribute
+     * @since Ant 1.9.12
+     */
+    public String getRuntime() {
+        return runtime;
+    }
+
+    /**
      * The classpath to use when looking up a resource.
      * @param classpath to add to any existing classpath
      */
@@ -452,7 +495,7 @@ public class Property extends Task {
 
     /**
      * set the property in the project to the value.
-     * if the task was give a file, resource or env attribute
+     * if the task was give a file, resource, env or runtime attribute
      * here is where it is loaded
      * @throws BuildException on error
      */
@@ -469,9 +512,9 @@ public class Property extends Task {
                                          getLocation());
             }
         } else {
-            if (url == null && file == null && resource == null && env == null) {
-                throw new BuildException("You must specify url, file, resource or "
-                                         + "environment when not using the "
+            if (url == null && file == null && resource == null && env == null && runtime == null) {
+                throw new BuildException("You must specify url, file, resource, "
+                                         + "environment or runtime when not using the "
                                          + "name attribute", getLocation());
             }
         }
@@ -513,6 +556,10 @@ public class Property extends Task {
             loadEnvironment(env);
         }
 
+        if (runtime != null) {
+            loadRuntime(runtime);
+        }
+
         if ((name != null) && (ref != null)) {
             try {
                 addProperty(name,
@@ -660,6 +707,25 @@ public class Property extends Task {
     }
 
     /**
+     * load the runtime values
+     * @param prefix prefix to place before them
+     * @since 1.9.12
+     */
+    protected void loadRuntime(String prefix) {
+        Properties props = new Properties();
+        if (!prefix.endsWith(".")) {
+            prefix += ".";
+        }
+        log("Loading Runtime properties " + prefix, Project.MSG_VERBOSE);
+        Runtime r = Runtime.getRuntime();
+        props.put(prefix + "availableProcessors", String.valueOf(r.availableProcessors()));
+        props.put(prefix + "freeMemory", String.valueOf(r.freeMemory()));
+        props.put(prefix + "maxMemory", String.valueOf(r.maxMemory()));
+        props.put(prefix + "totalMemory", String.valueOf(r.totalMemory()));
+        addProperties(props);
+    }
+
+    /**
      * iterate through a set of properties,
      * resolve them then assign them
      * @param props the properties to iterate over

http://git-wip-us.apache.org/repos/asf/ant/blob/5e99fc2c/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
----------------------------------------------------------------------
diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
index 7cead66..adb7843 100644
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
@@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs;
 
 import static org.apache.tools.ant.AntAssert.assertContains;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
@@ -136,4 +137,16 @@ public class PropertyTest {
 
     }
 
+    @Test
+    public void testRuntime() {
+        // should get no output at all
+        buildRule.executeTarget("testRuntime");
+        assertEquals(Runtime.getRuntime().availableProcessors(),
+                     Integer.parseInt(buildRule.getProject().getProperty("testruntime.availableProcessors")));
+        assertEquals(Runtime.getRuntime().maxMemory(),
+                     Long.parseLong(buildRule.getProject().getProperty("testruntime.maxMemory")));
+        assertNotNull(buildRule.getProject().getProperty("testruntime.freeMemory"));
+        assertNotNull(buildRule.getProject().getProperty("testruntime.totalMemory"));
+    }
+
 }


[2/2] ant git commit: Merge branch '1.9.x'

Posted by bo...@apache.org.
Merge branch '1.9.x'


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/6a9d7012
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/6a9d7012
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/6a9d7012

Branch: refs/heads/master
Commit: 6a9d701205dfe0f129bed0e740ebc1f76041c797
Parents: 22a05c5 5e99fc2
Author: Stefan Bodewig <bo...@apache.org>
Authored: Thu Apr 26 18:14:30 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Thu Apr 26 18:14:30 2018 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |  5 ++
 manual/Tasks/property.html                      | 23 +++++++
 src/etc/testcases/taskdefs/property.xml         |  4 ++
 .../org/apache/tools/ant/taskdefs/Property.java | 70 +++++++++++++++++++-
 .../apache/tools/ant/taskdefs/PropertyTest.java | 13 ++++
 5 files changed, 113 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/6a9d7012/WHATSNEW
----------------------------------------------------------------------
diff --cc WHATSNEW
index ae3b1c7,a87bd81..8076df1
--- a/WHATSNEW
+++ b/WHATSNEW
@@@ -39,7 -36,12 +39,12 @@@ Other changes
     finishing threads might fail.
     Bugzilla Report 62148
  
+  * <property> has a new attribute runtime which can be used to set
+    properties with values taken as snapshots from the
+    availableProcessors, freeMemory, maxMemory and totalMemory methods
+    of the Java Runtime class.
+ 
 -Changes from Ant 1.9.10 TO Ant 1.9.11
 +Changes from Ant 1.10.2 TO Ant 1.10.3
  =====================================
  
  Changes that could break older environments:

http://git-wip-us.apache.org/repos/asf/ant/blob/6a9d7012/manual/Tasks/property.html
----------------------------------------------------------------------
diff --cc manual/Tasks/property.html
index ed2c784,e8e57bb..199bf78
--- a/manual/Tasks/property.html
+++ b/manual/Tasks/property.html
@@@ -24,135 -24,169 +24,158 @@@
  
  <body>
  
 -<h2><a name="property">Property</a></h2>
 +<h2 id="property">Property</h2>
  <h3>Description</h3>
 -<p>Sets a <a href="../using.html#properties">property</a>
 -(by name and value), or set of properties (from file or
 -resource) in the project.  Properties are case sensitive.</p>
 - Properties are immutable: whoever sets a property first freezes it for the
 - rest of the build; they are most definitely not variables.
 +<p>Sets a <a href="../using.html#properties">property</a> (by name and value), or set of properties
 +(from file or resource) in the project.  Properties are case sensitive.</p>
 +<p>Properties are immutable: whoever sets a property first freezes it for the rest of the build;
 +they are most definitely not variables.</p>
  <p>There are seven ways to set properties:</p>
  <ul>
 -  <li>By supplying both the <i>name</i> and one of <i>value</i> or <i>location</i> attribute.</li>
 -  <li>By supplying the <i>name</i> and nested text.</li>
 -  <li>By supplying both the <i>name</i> and <i>refid</i> attribute.</li>
 -  <li>By setting the <i>file</i> 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, with the same rules about how
 -    non-ISO8859-1 characters must be escaped.</li>
 -  <li>By setting the <i>url</i> 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.</li>
 -  <li>By setting the <i>resource</i> attribute with the resource name of the
 -    property file to load. A resource is a property file on the current
 -    classpath, or on the specified classpath.</li>
 -  <li>By setting the <i>environment</i> 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.</li>
 +  <li>By supplying both the <var>name</var> and one of <var>value</var> or <var>location</var>
 +    attributes.</li>
 +  <li>By supplying the <var>name</var> and nested text.</li>
 +  <li>By supplying both the <var>name</var> and <var>refid</var> attributes.</li>
 +  <li>By setting the <var>file</var> 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 <code class="code">java.util.Properties</code>, with the same rules about how
 +    non-ISO-8859-1 characters must be escaped.</li>
 +  <li>By setting the <var>url</var> 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 <code class="code">java.util.Properties</code>.</li>
 +  <li>By setting the <var>resource</var> attribute with the resource name of the property file to
 +    load. A resource is a property file on the current classpath, or on the specified
 +    classpath.</li>
 +  <li>By setting the <var>environment</var> 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.</li>
+   <li>By setting the <i>runtime</i> attribute with a prefix to use.
+     Properties <code>prefix.availableProcessors</code>,
+     <code>prefix.freeMemory</code>, <code>prefix.totalMemory</code>
+     and <code>prefix.maxMemory</code> will be defined with values that
+     correspond to the corresponding methods of
+     the <a href="https://docs.oracle.com/javase/10/docs/api/java/lang/Runtime.html">Runtime</a>
+     class.</li>
  </ul>
 -<p>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.</p>
 -<p>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.</p>
 -<p>A list of predefined properties can be found <a
 -href="../properties.html#built-in-props">here</a>.</p>
 -<p>Since Apache Ant 1.8.0 it is possible to load properties defined in xml
 -according to <a href="http://java.sun.com/dtd/properties.dtd">Suns DTD</a>,
 -if Java5+ is present. For this the name of the file, resource or url has 
 -to end with <tt>.xml</tt>.</p>
 +<p>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.</p>
 +<p>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.</p>
 +<p>A list of predefined properties can be
 +found <a href="../properties.html#built-in-props">here</a>.</p>
 +<p><em>Since Apache Ant 1.8.0</em>, it is possible to load properties defined in XML according
 +to <a href="http://java.sun.com/dtd/properties.dtd" target="_top">Sun DTD</a>, when running on Java
 +5+. For this the name of the file, resource or url has to end with <samp>.xml</samp>.</p>
  
  <h3>Parameters</h3>
 -<table border="1" cellpadding="2" cellspacing="0">
 +<table class="attr">
    <tr>
 -    <td valign="top"><b>Attribute</b></td>
 -    <td valign="top"><b>Description</b></td>
 -    <td align="center" valign="top"><b>Required</b></td>
 +    <th>Attribute</th>
 +    <th>Description</th>
 +    <th>Required</th>
    </tr>
    <tr>
 -    <td valign="top">name</td>
 -    <td valign="top">the name of the property to set.</td>
 -    <td valign="top" align="center">No</td>
 +    <td>name</td>
 +    <td>the name of the property to set.</td>
 +    <td>No</td>
    </tr>
    <tr>
 -    <td valign="top">value</td>
 -    <td valign="top">the value of the property.</td>
 -    <td valign="middle" align="center" rowspan="3">One of these or
 -       nested text, when using the name attribute</td>
 +    <td>value</td>
 +    <td>the value of the property.</td>
 +    <td rowspan="3">One of these or nested text, when the <var>name</var> attribute is set</td>
    </tr>
    <tr>
 -    <td valign="top">location</td>
 -    <td valign="top">Sets the property to the absolute filename of the
 -      given file. If the value of this attribute is an absolute path, it
 -      is left unchanged (with / and \ characters converted to the
 -      current platforms conventions). Otherwise it is taken as a path
 -      relative to the project's basedir and expanded.</td>
 +    <td>location</td>
 +    <td class="left">Sets the property to the absolute filename of the given file. If the value of
 +      this attribute is an absolute path, it is left unchanged (with <q>/</q> and <q>\</q>
 +      characters converted to the current platforms conventions). Otherwise it is taken as a path
 +      relative to the project's <var>basedir</var> and expanded.</td>
    </tr>
    <tr>
 -    <td valign="top">refid</td>
 -    <td valign="top"><a href="../using.html#references">Reference</a> to an object
 -      defined elsewhere. Only yields reasonable results for references
 -      to <a href="../using.html#path">PATH like structures</a> or properties.</td>
 +    <td>refid</td>
 +    <td class="left"><a href="../using.html#references">Reference</a> to an object defined
 +      elsewhere. Only yields reasonable results for references
 +      to <a href="../using.html#path">path-like structures</a> or properties.</td>
    </tr>
    <tr>
 -    <td valign="top">resource</td>
 -    <td valign="top"> the name of the classpath resource containing
 -      properties settings in properties file format.</td>
 -    <td valign="middle" align="center" rowspan="4">One of these, when
 -      <b>not</b> using the name attribute</td>
 +    <td>resource</td>
 +    <td>the name of the classpath resource containing properties settings in properties file
 +      format.</td>
 +    <td rowspan="4">One of these, <strong>unless</strong> the <var>name</var> attribute is set</td>
    </tr>
    <tr>
 -    <td valign="top">file</td>
 -    <td valign="top">the location of the properties file to load.</td>
 +    <td>file</td>
 +    <td class="left">the location of the properties file to load.</td>
    </tr>
    <tr>
 -    <td valign="top">url</td>
 -    <td valign="top">a url containing properties-format settings.</td>
 +    <td>url</td>
 +    <td class="left">a URL containing properties-format settings.</td>
    </tr>
    <tr>
 -    <td valign="top">environment</td>
 -    <td valign="top">the prefix to use when retrieving environment variables. Thus
 -    if you specify environment=&quot;myenv&quot; you will be able to access OS-specific
 -    environment variables via property names &quot;myenv.PATH&quot; or
 -    &quot;myenv.TERM&quot;. Note that if you supply a property name with a final
 -    &quot;.&quot; it will not be doubled; i.e. environment=&quot;myenv.&quot; will still
 -    allow access of environment variables through &quot;myenv.PATH&quot; and
 -    &quot;myenv.TERM&quot;. This functionality is currently only implemented
 -    on <a href="#notes-env">select platforms</a>. Feel free to send patches to increase the
 -    number of platforms on which this functionality is supported ;).<br>
 -    Note also that properties are case-sensitive, even if the
 -    environment variables on your operating system are not; e.g. Windows 2000's
 -    system path variable is set to an Ant property named "env.Path"
 -    rather than "env.PATH".</td>
 +    <td>environment</td>
 +    <td class="left">the prefix to use when retrieving environment variables. Thus if you
 +      specify <var>environment</var>=<q>myenv</q> you will be able to access OS-specific environment
 +      variables via property names <code>myenv.PATH</code> or <code>myenv.TERM</code>. Note that if
 +      you supply a property <var>name</var> with a final <q>.</q> it will not be doubled;
 +      i.e. <var>environment</var>=<q>myenv.</q> will still allow access of environment variables
 +      through <code>myenv.PATH</code> and <code>myenv.TERM</code>. This functionality is currently
 +      only implemented on <a href="#notes-env">select platforms</a>. Feel free to send patches to
 +      increase the number of platforms on which this functionality is supported ;-).<br/>Note also
 +      that properties are case-sensitive, even if the environment variables on your operating system
 +      are not; e.g. Windows 2000 or later system path variable is set to an Ant property
 +      named <code>env.Path</code> rather than <code>env.PATH</code>.</td>
    </tr>
    <tr>
 -    <td valign="top">runtime</td>
 -    <td valign="top">the prefix to use when retrieving Runtime properties. Thus
 -    if you specify runtime=&quot;myrt&quot; you will be able to access
 -    runtime values corresponding to methods in
++    <td>runtime</td>
++    <td>the prefix to use when retrieving Runtime properties. Thus if
++    you specify <var>runtime</var>=<q>myrt</q> you will be able to
++    access runtime values corresponding to methods in
+     the <a href="https://docs.oracle.com/javase/10/docs/api/java/lang/Runtime.html">Runtime</a>
 -    class via property names &quot;myrt.availableProcessors&quot;,
 -    &quot;myrt.maxMemory&quot;, &quot;myrt.totalMemory&quot; or
 -    &quot;myrt.freeMemory&quot;. Note that if you supply a property name with a final
 -    &quot;.&quot; it will not be doubled; i.e. runtime=&quot;myrt.&quot; will still
 -    allow access of prpperties through &quot;myrt.maxMemory&quot;.<br>
++    class via property names <code>myrt.availableProcessors</code>,
++    <code>myrt.maxMemory</code>, <code>myrt.totalMemory</code> or
++    <code>myrt.freeMemory</code>. Note that if you supply a property name with a final
++    <code>.</code> it will not be doubled; i.e. runtime=<code>myrt.</code> will still
++    allow access of prpperties through <code>myrt.maxMemory</code>.<br>
+     Note also that the property values are snapshots taken at the point in time
+     when the <code>property</code> has been executed.
 -    <em>Since Ant 1.9.12</em>
++    <em>Since Ant 1.10.4</em>
+     </td>
+   </tr>
+   <tr>
 -    <td valign="top">classpath</td>
 -    <td valign="top">the classpath to use when looking up a resource.</td>
 -    <td align="center" valign="top">No</td>
 +    <td>classpath</td>
 +    <td>the classpath to use when looking up a resource.</td>
 +    <td>No</td>
    </tr>
    <tr>
 -    <td valign="top">classpathref</td>
 -    <td valign="top">the classpath to use when looking up a resource,
 -      given as <a href="../using.html#references">reference</a> to a <code>&lt;path&gt;</code> defined
 +    <td>classpathref</td>
 +    <td>the classpath to use when looking up a resource, given
 +      as <a href="../using.html#references">reference</a> to a <code>&lt;path&gt;</code> defined
        elsewhere..</td>
 -    <td align="center" valign="top">No</td>
 +    <td>No</td>
    </tr>
    <tr>
 -    <td valign="top">prefix</td>
 -    <td valign="top">Prefix to apply to properties loaded using <code>file</code>,
 -    <code>resource</code>, or <code>url</code>.
 -      A "." is appended to the prefix if not specified.</td>
 -    <td align="center" valign="top">No</td>
 +    <td>prefix</td>
 +    <td>Prefix to apply to properties loaded using <var>file</var>, <var>resource</var>,
 +      or <var>url</var>.  A <q>.</q> is appended to the prefix if not specified.</td>
 +    <td>No</td>
    </tr>
    <tr>
 -    <td valign="top">prefixValues</td>
 -    <td valign="top">Whether to apply the prefix when expanding the
 -      right hand side of properties loaded using <code>file</code>,
 -      <code>resource</code>, or <code>url</code>.
 -      <em>Since Ant 1.8.2</em></td>
 -    <td align="center" valign="top">No (default=<tt>false</tt>)</td>
 +    <td>prefixValues</td>
 +    <td>Whether to apply the prefix when expanding the right hand side of properties loaded
 +      using <var>file</var>, <var>resource</var>, or <var>url</var>.  <em>Since Ant 1.8.2</em></td>
 +    <td>No; default is <q>false</q></td>
    </tr>
    <tr>
 -    <td valign="top">relative</td>
 -    <td valign="top">If set to <tt>true</tt> the relative path
 -      to <tt>basedir</tt> is set.  <em>Since Ant 1.8.0</em></td>
 -    <td align="center" valign="top">No (default=<tt>false</tt>)</td>
 +    <td>relative</td>
 +    <td>If set to <q>true</q> the relative path to <var>basedir</var> is set.  <em>Since Ant
 +      1.8.0</em></td>
 +    <td>No; default is <q>false</q></td>
    </tr>
    <tr>
 -    <td valign="top">basedir</td>
 -    <td valign="top">The basedir to calculate the relative path
 -      from.  <em>Since Ant 1.8.0</em></td>
 -    <td align="center" valign="top">No (default=<tt>${basedir}</tt>)</td>
 +    <td>basedir</td>
 +    <td>The <var>basedir</var> to calculate the relative path from.  <em>Since Ant 1.8.0</em></td>
 +    <td>No; default is project's <var>basedir</var></td>
    </tr>
  </table>
  

http://git-wip-us.apache.org/repos/asf/ant/blob/6a9d7012/src/main/org/apache/tools/ant/taskdefs/Property.java
----------------------------------------------------------------------
diff --cc src/main/org/apache/tools/ant/taskdefs/Property.java
index 4240bd5,a6b51a2..1cfd268
--- a/src/main/org/apache/tools/ant/taskdefs/Property.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Property.java
@@@ -386,6 -395,42 +393,42 @@@ public class Property extends Task 
      }
  
      /**
+      * Prefix to use when retrieving Runtime properties.
+      *
+      * <p>Properties <code>prefix.availableProcessors</code>,
+      * <code>prefix.freeMemory</code>, <code>prefix.totalMemory</code>
+      * and <code>prefix.maxMemory</code> will be defined with values
+      * that correspond to the corresponding methods of the {@link
+      * Runtime} class.</p>
+      *
+      * <p>Note that if you supply a prefix name with a final
+      * &quot;.&quot; it will not be doubled. ie
+      * runtime=&quot;myrt.&quot; will still allow access of property
+      * through &quot;myrt.availableProcessors&quot; and
+      * &quot;myrt.freeMemory&quot;.</p>
+      *
+      * <p>The property values are snapshots taken at the point in time
+      * when the <code>property</code> has been executed.</p>
+      *
+      * @param prefix prefix
+      *
+      * @ant.attribute group="noname"
 -     * @since Ant 1.9.12
++     * @since Ant 1.10.4
+      */
+     public void setRuntime(String prefix) {
+         this.runtime = prefix;
+     }
+ 
+     /**
+      * Get the runtime attribute.
+      * @return the runtime attribute
 -     * @since Ant 1.9.12
++     * @since Ant 1.10.4
+      */
+     public String getRuntime() {
+         return runtime;
+     }
+ 
+     /**
       * The classpath to use when looking up a resource.
       * @param classpath to add to any existing classpath
       */
@@@ -462,16 -507,15 +505,16 @@@
  
          if (name != null) {
              if (untypedValue == null && ref == null) {
 -                throw new BuildException("You must specify value, location or "
 -                                         + "refid with the name attribute",
 -                                         getLocation());
 +                throw new BuildException(
 +                    "You must specify value, location or refid with the name attribute",
 +                    getLocation());
              }
          } else {
 -            if (url == null && file == null && resource == null && env == null && runtime == null) {
 -                throw new BuildException("You must specify url, file, resource, "
 -                                         + "environment or runtime when not using the "
 -                                         + "name attribute", getLocation());
 +            if (url == null && file == null && resource == null
 +                && env == null) {
 +                throw new BuildException(
-                     "You must specify url, file, resource or environment when not using the name attribute",
++                    "You must specify url, file, resource, environment or runtime when not using the name attribute",
 +                    getLocation());
              }
          }
  
@@@ -515,7 -556,11 +558,11 @@@
              loadEnvironment(env);
          }
  
+         if (runtime != null) {
+             loadRuntime(runtime);
+         }
+ 
 -        if ((name != null) && (ref != null)) {
 +        if (name != null && ref != null) {
              try {
                  addProperty(name,
                              ref.getReferencedObject(getProject()).toString());
@@@ -651,6 -707,25 +698,25 @@@
      }
  
      /**
+      * load the runtime values
+      * @param prefix prefix to place before them
 -     * @since 1.9.12
++     * @since 1.10.4
+      */
+     protected void loadRuntime(String prefix) {
+         Properties props = new Properties();
+         if (!prefix.endsWith(".")) {
+             prefix += ".";
+         }
+         log("Loading Runtime properties " + prefix, Project.MSG_VERBOSE);
+         Runtime r = Runtime.getRuntime();
+         props.put(prefix + "availableProcessors", String.valueOf(r.availableProcessors()));
+         props.put(prefix + "freeMemory", String.valueOf(r.freeMemory()));
+         props.put(prefix + "maxMemory", String.valueOf(r.maxMemory()));
+         props.put(prefix + "totalMemory", String.valueOf(r.totalMemory()));
+         addProperties(props);
+     }
+ 
+     /**
       * iterate through a set of properties,
       * resolve them then assign them
       * @param props the properties to iterate over

http://git-wip-us.apache.org/repos/asf/ant/blob/6a9d7012/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
----------------------------------------------------------------------
diff --cc src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
index 080b63f,adb7843..4115339
--- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
+++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
@@@ -18,10 -18,11 +18,11 @@@
  
  package org.apache.tools.ant.taskdefs;
  
 -import static org.apache.tools.ant.AntAssert.assertContains;
 +import static org.hamcrest.Matchers.containsString;
  import static org.junit.Assert.assertEquals;
+ import static org.junit.Assert.assertNotNull;
 -import static org.junit.Assert.assertTrue;
 -import static org.junit.Assert.fail;
 +import static org.junit.Assert.assertThat;
 +import static org.junit.Assume.assumeNoException;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.BuildFileRule;
@@@ -132,6 -134,19 +133,18 @@@ public class PropertyTest 
          buildRule.executeTarget("testXmlProperty");
          assertEquals("ONE", buildRule.getProject().getProperty("xml.one"));
          assertEquals("TWO", buildRule.getProject().getProperty("xml.two"));
 -
      }
  
+     @Test
+     public void testRuntime() {
+         // should get no output at all
+         buildRule.executeTarget("testRuntime");
+         assertEquals(Runtime.getRuntime().availableProcessors(),
+                      Integer.parseInt(buildRule.getProject().getProperty("testruntime.availableProcessors")));
+         assertEquals(Runtime.getRuntime().maxMemory(),
+                      Long.parseLong(buildRule.getProject().getProperty("testruntime.maxMemory")));
+         assertNotNull(buildRule.getProject().getProperty("testruntime.freeMemory"));
+         assertNotNull(buildRule.getProject().getProperty("testruntime.totalMemory"));
+     }
+ 
  }