incubator-ivy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xav...@apache.org
Subject svn commit: r583068 - in /incubator/ivy/core/trunk/src/java/org/apache/ivy: Ivy.java util/Message.java
Date Tue, 09 Oct 2007 08:00:24 GMT
Author: xavier
Date: Tue Oct  9 01:00:23 2007
New Revision: 583068

URL: http://svn.apache.org/viewvc?rev=583068&view=rev
Log:
make Ivy engine metadata (version, date and home URL) accessible with the API, instead of
only displayed by the Message class.

Modified:
    incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
    incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java?rev=583068&r1=583067&r2=583068&view=diff
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/Ivy.java Tue Oct  9 01:00:23 2007
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -26,6 +27,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 import org.apache.ivy.core.IvyContext;
 import org.apache.ivy.core.cache.CacheManager;
@@ -82,6 +84,65 @@
     private static final int KILO = 1024;
 
     public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
+    
+    /**
+     * the current version of Ivy, as displayed on the console when 
+     * Ivy is initialized
+     */
+    private static final String IVY_VERSION;
+    /**
+     * the date at which this version of Ivy has been built.
+     * May be empty if unknown.
+     */
+    private static final String IVY_DATE;
+    
+    static {
+        // initialize IVY_VERSION and IVY_DATE
+        Properties props = new Properties();
+        URL moduleURL = Message.class.getResource("/module.properties");
+        if (moduleURL != null) {
+            try {
+                InputStream module = moduleURL.openStream();
+                props.load(module);
+                module.close();
+            } catch (IOException e) {
+                // ignore this exception, we will initialize with default values
+            }
+        }
+        IVY_VERSION = props.getProperty("version", "non official version");
+        IVY_DATE = props.getProperty("date", "");
+    }
+    
+    /**
+     * Returns the current version of Ivy, as displayed on the console when 
+     * Ivy is initialized.
+     * 
+     * @return the current version of Ivy
+     * @see #getIvyVersion()
+     */
+    public static String getIvyVersion() {
+        return IVY_VERSION;
+    }
+
+    /**
+     * Returns the date at which this version of Ivy has been built.
+     * <p>
+     * May be empty if unknown.
+     * 
+     * @return the date at which this version of Ivy has been built
+     * @see #getIvyVersion()
+     */
+    public static String getIvyDate() {
+        return IVY_DATE;
+    }
+    
+    /**
+     * Returns the URL at which Ivy web site can be found.
+     * @return the URL at which Ivy web site can be found
+     */
+    public static String getIvyHomeURL() {
+        return "http://incubator.apache.org/ivy/";
+    }
 
     public static Ivy newInstance() {
         Ivy ivy = new Ivy();

Modified: incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java
URL: http://svn.apache.org/viewvc/incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java?rev=583068&r1=583067&r2=583068&view=diff
==============================================================================
--- incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java (original)
+++ incubator/ivy/core/trunk/src/java/org/apache/ivy/util/Message.java Tue Oct  9 01:00:23
2007
@@ -17,14 +17,11 @@
  */
 package org.apache.ivy.util;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Properties;
 
+import org.apache.ivy.Ivy;
 import org.apache.ivy.core.IvyContext;
 
 /**
@@ -86,22 +83,8 @@
 
     private static void showInfo() {
         if (!showedInfo) {
-            Properties props = new Properties();
-            URL moduleURL = Message.class.getResource("/module.properties");
-            if (moduleURL != null) {
-                try {
-                    InputStream module = moduleURL.openStream();
-                    props.load(module);
-                    debug("version information loaded from " + moduleURL);
-                    info(":: Ivy " + props.getProperty("version") + " - "
-                           + props.getProperty("date") + " :: http://incubator.apache.org/ivy/
::");
-                    module.close();
-                } catch (IOException e) {
-                    info(":: Ivy non official version :: http://incubator.apache.org/ivy/
::");
-                }
-            } else {
-                info(":: Ivy non official version :: http://incubator.apache.org/ivy/ ::");
-            }
+            info(":: Ivy " + Ivy.getIvyVersion() + " - "
+                   + Ivy.getIvyDate() + " :: " + Ivy.getIvyHomeURL() + " ::");
             showedInfo = true;
         }
     }



Mime
View raw message