]> source.dussan.org Git - archiva.git/commitdiff
fix the version handling since the group ID change, and simplify in the process
authorBrett Porter <brett@apache.org>
Mon, 31 Mar 2008 03:25:25 +0000 (03:25 +0000)
committerBrett Porter <brett@apache.org>
Mon, 31 Mar 2008 03:25:25 +0000 (03:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@642863 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaVersion.java

index edfc6b6954c3b4b14feb6b4e8eb5ac443e41e910..34ab2f2821fa60f37d844bbb7671cd2819bf8b81 100644 (file)
@@ -20,6 +20,7 @@ package org.apache.maven.archiva.web.startup;
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.io.IOUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -47,67 +48,34 @@ public class ArchivaVersion
             return version;
         }
         
-        /* This is the search order of modules to find the version.
-          @todo is this really necessary? Just use webapp?
-         */
-        String[] modules = new String[] {
-            "archiva-common",
-            "archiva-configuration",
-            "archiva-database",
-            "archiva-consumer-api",
-            "archiva-core-consumers",
-            "archiva-signature-consumers",
-            "archiva-database-consumers",
-            "archiva-lucene-consumers",
-            "archiva-indexer",
-            "archiva-model",
-            "archiva-policies",
-            "archiva-proxy",
-            "archiva-report-manager",
-            "archiva-artifact-reports",
-            "archiva-project-reports",
-            "archiva-metadata-reports",
-            "archiva-repository-layer",
-            "archiva-scheduled",
-            "archiva-webapp",
-            "archiva-security",
-            "archiva-applet",
-            "archiva-xml-tools" };
-
-        for ( int i = 0; i < modules.length; i++ )
+        InputStream is = cloader.getResourceAsStream( "/META-INF/maven/org.apache.archiva/archiva-configuration/pom.properties" );
+        if ( is != null )
         {
-            String module = modules[i];
-            URL pomurl = findModulePom( cloader, module );
-            if ( pomurl != null )
+            try
             {
-                try
-                {
-                    Properties props = new Properties();
-                    InputStream is = pomurl.openStream();
-                    props.load( is );
-                    String version = props.getProperty( "version" );
-                    if ( StringUtils.isNotBlank( version ) )
-                    {
-                        ArchivaVersion.version = version;
-                        return version;
-                    }
-                }
-                catch ( IOException e )
+                Properties props = new Properties();
+                props.load( is );
+                String version = props.getProperty( "version" );
+                if ( StringUtils.isNotBlank( version ) )
                 {
-                    /* do nothing */
+                    ArchivaVersion.version = version;
+                    return version;
                 }
             }
+            catch ( IOException e )
+            {
+                /* do nothing */
+            }
+            finally
+            {
+                IOUtils.closeQuietly( is );
+            }
         }
 
-        version = "<Unknown Version>";
+        ArchivaVersion.version = "";
         return version;
     }
 
-    private static URL findModulePom( ClassLoader cloader, String module )
-    {
-        return cloader.getResource( "/META-INF/maven/org.apache.maven.archiva/" + module + "/pom.properties" );
-    }
-
     public static String getVersion()
     {
         return version;