|
| 1 | +/* |
| 2 | + * Copyright 2021 OPPO. All rights reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.oppo.shuttle.rss; |
| 18 | + |
| 19 | +import com.oppo.shuttle.rss.common.Constants; |
| 20 | +import com.oppo.shuttle.rss.exceptions.Ors2FileException; |
| 21 | + |
| 22 | +import java.io.IOException; |
| 23 | +import java.io.InputStream; |
| 24 | +import java.util.Properties; |
| 25 | + |
| 26 | +public class BuildVersion { |
| 27 | + |
| 28 | + public static String projectVersion = Constants.UNKNOWN_BUILD_VERSION; |
| 29 | + public static String gitCommitVersion = Constants.UNKNOWN_BUILD_VERSION; |
| 30 | + |
| 31 | + static { |
| 32 | + try (InputStream versionFileInputStream = |
| 33 | + Thread.currentThread().getContextClassLoader().getResourceAsStream(Constants.BUILD_VERSION_FILE)) { |
| 34 | + Properties properties = new Properties(); |
| 35 | + properties.load(versionFileInputStream); |
| 36 | + projectVersion = properties.getProperty(Constants.PROJECT_VERSION_KEY); |
| 37 | + gitCommitVersion = properties.getProperty(Constants.GIT_COMMIT_VERSION_KEY); |
| 38 | + } catch (IOException e) { |
| 39 | + throw new Ors2FileException("Failed to open build version file " + Constants.BUILD_VERSION_FILE); |
| 40 | + } |
| 41 | + } |
| 42 | +} |
0 commit comments