Info.java revision 1062
230N/A/*
230N/A * CDDL HEADER START
230N/A *
230N/A * The contents of this file are subject to the terms of the
230N/A * Common Development and Distribution License (the "License").
230N/A * You may not use this file except in compliance with the License.
230N/A *
230N/A * See LICENSE.txt included in this distribution for the specific
230N/A * language governing permissions and limitations under the License.
230N/A *
230N/A * When distributing Covered Code, include this CDDL HEADER in each
230N/A * file and include the License file at LICENSE.txt.
230N/A * If applicable, add the following below this CDDL HEADER, with the
230N/A * fields enclosed by brackets "[]" replaced with your own identifying
230N/A * information: Portions Copyright [yyyy] [name of copyright owner]
230N/A *
230N/A * CDDL HEADER END
230N/A */
230N/A
230N/A/*
1062N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
230N/A */
230N/Apackage org.opensolaris.opengrok;
230N/A
230N/Aimport java.io.IOException;
230N/Aimport java.io.InputStream;
230N/Aimport java.util.Properties;
230N/A
230N/A/**
230N/A * Utility class to get information of the OpenGrok version.
230N/A *
230N/A * @author Trond Norbye
230N/A */
439N/A@SuppressWarnings("PMD.AvoidThrowingRawExceptionTypes")
439N/Apublic final class Info {
230N/A private static final Properties properties = new Properties();
230N/A
368N/A private static final String VERSION;
368N/A private static final String REVISION;
340N/A
230N/A static {
972N/A InputStream in = null;
230N/A try {
857N/A in = Info.class.getResourceAsStream("info.properties");
230N/A if (in != null) {
230N/A properties.load(in);
230N/A }
340N/A VERSION = properties.getProperty("version", "unknown");
340N/A REVISION = properties.getProperty("changeset", "unknown");
230N/A } catch (IOException ioe) {
230N/A throw new RuntimeException(ioe);
857N/A } finally {
857N/A try {
972N/A if (in != null) {
972N/A in.close();
972N/A }
972N/A } catch (IOException ioe) {
972N/A System.err.println(ioe.getMessage()); //NOPMD
857N/A }
972N/A }
230N/A }
230N/A
1062N/A /**
1062N/A * get major version
1062N/A * @return major version
1062N/A */
230N/A public static String getVersion() {
340N/A return VERSION;
340N/A }
340N/A
1062N/A /**
1062N/A * get full version (product vMajor revMinor)
1062N/A * @return full version
1062N/A */
340N/A public static String getFullVersion() {
340N/A return "OpenGrok v" + VERSION + " rev " + REVISION;
230N/A }
230N/A
1062N/A /**
1062N/A * get minor version
1062N/A * @return minor version
1062N/A */
230N/A public static String getRevision() {
340N/A return REVISION;
230N/A }
230N/A
230N/A private Info() {
230N/A }
230N/A}