001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/framework/version/Version.java $ 002 /*---------------------------------------------------------------------------- 003 This file is part of deegree, http://deegree.org/ 004 Copyright (C) 2001-2009 by: 005 Department of Geography, University of Bonn 006 and 007 lat/lon GmbH 008 009 This library is free software; you can redistribute it and/or modify it under 010 the terms of the GNU Lesser General Public License as published by the Free 011 Software Foundation; either version 2.1 of the License, or (at your option) 012 any later version. 013 This library is distributed in the hope that it will be useful, but WITHOUT 014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 016 details. 017 You should have received a copy of the GNU Lesser General Public License 018 along with this library; if not, write to the Free Software Foundation, Inc., 019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 020 021 Contact information: 022 023 lat/lon GmbH 024 Aennchenstr. 19, 53177 Bonn 025 Germany 026 http://lat-lon.de/ 027 028 Department of Geography, University of Bonn 029 Prof. Dr. Klaus Greve 030 Postfach 1147, 53001 Bonn 031 Germany 032 http://www.geographie.uni-bonn.de/deegree/ 033 034 e-mail: info@deegree.org 035 ----------------------------------------------------------------------------*/ 036 package org.deegree.framework.version; 037 038 import java.util.Properties; 039 040 import org.deegree.framework.util.BootLogger; 041 042 /** 043 * The version number is created by 3 parts, the first represents the version number, the second a 044 * essential update of a release, the third the build number. The version number could be numeric or 045 * alphanumeric, e.g. 'Foo2' or '2.0'.<BR> 046 * e.g.:<BR> 047 * 2.0alpha.142 - version no. 2, release 0 alpha, build 142<BR> 048 * 2.0beta.178 - version no. 2, release 0 beta, build 178 <BR> 049 * 2.0.198 - version no. 2, release 0, build 198 <BR> 050 * 051 * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe</A> 052 * 053 * @author last edited by: $Author: mschneider $ 054 * 055 * @version 3.0 . $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $ 056 */ 057 public final class Version { 058 059 private static String BUILD_DATE; 060 061 private static String VERSION_NUMBER; 062 063 private static String BUILD_NUMBER; 064 065 private static String BUILD_BY; 066 067 private static String SVN_REVISION, SVN_PATH; 068 069 /* 070 * Class loader to get version properties from resource file 071 */ 072 static { 073 try { 074 // fetch version property 075 Properties versionProps = new Properties(); 076 versionProps.load( Version.class.getResourceAsStream( "version.properties" ) ); 077 VERSION_NUMBER = versionProps.getProperty( "version.number" ); 078 079 // fetch build properties 080 Properties buildProps = new Properties(); 081 buildProps.load( Version.class.getResourceAsStream( "buildId.properties" ) ); 082 BUILD_DATE = buildProps.getProperty( "build.date" ); 083 BUILD_NUMBER = buildProps.getProperty( "build.number" ); 084 BUILD_BY = buildProps.getProperty( "build.by" ); 085 SVN_REVISION = buildProps.getProperty( "svn.revision" ).trim(); 086 SVN_PATH = buildProps.getProperty( "svn.path" ).trim(); 087 } catch ( Exception ex ) { 088 BootLogger.logError( "Error fetching version / build properties: " + ex.getMessage(), ex ); 089 } 090 } 091 092 private Version() { 093 // Don't let anyone instantiate this class. 094 } 095 096 /** 097 * Returns the version of the application. The version number is created by 3 parts, the first 098 * represents the version number, the second a essential update of a release, the third the 099 * build number. The version number could be numeric or alphanumeric, e.g. 'Foo2' or '2.0'. 100 * <P> 101 * e.g.:<BR> 102 * 1.0.42 - version no. 1, release 0, build 42<BR> 103 * 1.1.78 - version no. 1, release 1, build 78<BR> 104 * 2.0.98 - version no. 2, release 0, build 98<BR> 105 * 106 * @return the version string 107 */ 108 public static String getVersion() { 109 final String s = getVersionNumber() + " (" + getBuildDate() + " build-" + getBuildNumber() + "-" + getBuildBy() 110 + ")"; 111 return s; 112 } 113 114 /** 115 * Returns the version number. 116 * 117 * @return the version number 118 */ 119 public static String getVersionNumber() { 120 return Version.VERSION_NUMBER; 121 } 122 123 /** 124 * Returns the current build number. 125 * 126 * @return the current build number 127 */ 128 public static String getBuildNumber() { 129 return Version.BUILD_NUMBER; 130 } 131 132 /** 133 * Returns the date string when the current build was created. 134 * 135 * @return the date as String 136 */ 137 public static String getBuildDate() { 138 return Version.BUILD_DATE; 139 } 140 141 /** 142 * Returns the name of the builder. 143 * 144 * @return the name of the builder 145 */ 146 public static String getBuildBy() { 147 return Version.BUILD_BY; 148 } 149 150 /** 151 * @return the svn revision number and path 152 */ 153 public static String getSvnInfo() { 154 return "revision " + SVN_REVISION + " of " + SVN_PATH; 155 } 156 157 /** 158 * @return the svn revision number 159 */ 160 public static String getSvnRevision() { 161 return SVN_REVISION; 162 } 163 164 /** 165 * @return the svn path 166 */ 167 public static String getSvnPath() { 168 return SVN_PATH; 169 } 170 171 /** 172 * @param args 173 */ 174 public static void main( String[] args ) { 175 System.out.println( "deegree version: " + getVersion() + "\n" + getSvnInfo() ); 176 } 177 }