2021-10-07 15:48:52 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Paul Schaub <vanitasvitae@fsfe.org>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
package org.pgpainless.sop;
|
2020-12-16 20:09:01 +01:00
|
|
|
|
2021-03-05 13:04:28 +01:00
|
|
|
import java.io.IOException;
|
2021-10-04 16:28:56 +02:00
|
|
|
import java.io.InputStream;
|
2021-03-05 13:04:28 +01:00
|
|
|
import java.util.Properties;
|
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
import sop.operation.Version;
|
2021-03-05 13:04:28 +01:00
|
|
|
|
2021-07-15 16:55:13 +02:00
|
|
|
public class VersionImpl implements Version {
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "PGPainless-SOP";
|
|
|
|
}
|
2020-11-26 11:00:48 +01:00
|
|
|
|
|
|
|
@Override
|
2021-07-15 16:55:13 +02:00
|
|
|
public String getVersion() {
|
2021-03-05 13:04:28 +01:00
|
|
|
// See https://stackoverflow.com/a/50119235
|
|
|
|
String version;
|
|
|
|
try {
|
|
|
|
Properties properties = new Properties();
|
2021-10-04 16:28:56 +02:00
|
|
|
InputStream propertiesFileIn = getClass().getResourceAsStream("/version.properties");
|
|
|
|
if (propertiesFileIn == null) {
|
|
|
|
throw new IOException("File version.properties not found.");
|
|
|
|
}
|
|
|
|
properties.load(propertiesFileIn);
|
2021-03-05 13:04:28 +01:00
|
|
|
version = properties.getProperty("version");
|
|
|
|
} catch (IOException e) {
|
|
|
|
version = "DEVELOPMENT";
|
|
|
|
}
|
2021-07-15 16:55:13 +02:00
|
|
|
return version;
|
2020-11-26 11:00:48 +01:00
|
|
|
}
|
|
|
|
}
|