From: Brett Porter Date: Mon, 31 Mar 2008 03:25:25 +0000 (+0000) Subject: fix the version handling since the group ID change, and simplify in the process X-Git-Tag: archiva-r676265~231 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a49a0f2863495845ee39a2f0f33f16325e9f3813;p=archiva.git fix the version handling since the group ID change, and simplify in the process git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@642863 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaVersion.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaVersion.java index edfc6b695..34ab2f282 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaVersion.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ArchivaVersion.java @@ -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 = ""; + 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;