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