pgpainless/pgpainless-sop/src/main/java/org/pgpainless/sop/VersionImpl.java

48 lines
1.5 KiB
Java
Raw Normal View History

2020-12-16 20:09:01 +01:00
/*
* Copyright 2021 Paul Schaub.
2020-12-16 20:09:01 +01:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.pgpainless.sop;
2020-12-16 20:09:01 +01:00
import java.io.IOException;
2021-10-04 16:28:56 +02:00
import java.io.InputStream;
import java.util.Properties;
import sop.operation.Version;
public class VersionImpl implements Version {
@Override
public String getName() {
return "PGPainless-SOP";
}
2020-11-26 11:00:48 +01:00
@Override
public String getVersion() {
// 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);
version = properties.getProperty("version");
} catch (IOException e) {
version = "DEVELOPMENT";
}
return version;
2020-11-26 11:00:48 +01:00
}
}