Hi,

This is a very simple patch which will allow Tasks to determine the version of Ant they are being run in. This is especially useful for knowing which methods on Project are available.
e.g.
public void log(String message, Throwable throwable, int msgLevel) et al

are only available @since 1.7.


Cheers,
Nick Pellow





Index: src/main/org/apache/tools/ant/Main.java
===================================================================
--- src/main/org/apache/tools/ant/Main.java     (revision 675106)
+++ src/main/org/apache/tools/ant/Main.java     (working copy)
@@ -929,6 +929,21 @@
     private static String antVersion = null;
 
     /**
+     * The version string, as defined by the VERSION property in version.txt.
+     */
+    private static String version = null;
+
+    /**
+     * Returns just the ant version String.
+     *
+     * This will be generally of the form: "X.Y.Z" for any X,Y,Z integer values
+     * and allows a lexicographical comparison of Ant versions.
+     * @return the ant version
+     */
+    public static String getVersion() {
+        return version;
+    }
+    /**
      * Returns the Ant version information, if available. Once the information
      * has been loaded once, it's cached and returned from the cache on future
      * calls.
@@ -949,7 +964,8 @@
 
                 StringBuffer msg = new StringBuffer();
                 msg.append("Apache Ant version ");
-                msg.append(props.getProperty("VERSION"));
+                version = props.getProperty("VERSION");
+                msg.append(version);
                 msg.append(" compiled on ");
                 msg.append(props.getProperty("DATE"));
                 antVersion = msg.toString();

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to