summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/prelude/VespaSVersionRetriever.java
blob: 9d6d4f55fb3ed01349b24fd5ec55072253269efd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.prelude;

import java.io.IOException;
import java.util.jar.Manifest;

/**
 * Retrieves Vespa-Version from the manifest file.
 *
 * @author tonytv
 */
public class VespaSVersionRetriever {

    public static String getVersion() {
        return version;
    }

    private static String version = retrieveVersion();

    private static String retrieveVersion() {
        try {
            Manifest manifest = new Manifest(VespaSVersionRetriever.class.getResourceAsStream("/META-INF/MANIFEST.MF"));
            manifest.getMainAttributes().entrySet();
            return manifest.getMainAttributes().getValue("Vespa-Version");
        } catch (IOException e) {
            return "not available.";
        }
    }
}