From 86f1fe8b6621110741df4fddf5fe866ba844e8c7 Mon Sep 17 00:00:00 2001 From: Jakob Heher Date: Fri, 18 Feb 2022 12:27:14 +0100 Subject: move to a more stable version detection mechanism, powered by maven; cf. #63 #65 --- pdf-over-commons/pom.xml | 9 +++++++++ .../main/java/at/asit/pdfover/commons/Constants.java | 18 +++++++++++++++++- pdf-over-commons/src/main/resources/version.properties | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 pdf-over-commons/src/main/resources/version.properties diff --git a/pdf-over-commons/pom.xml b/pdf-over-commons/pom.xml index d62f6257..d9c944ed 100644 --- a/pdf-over-commons/pom.xml +++ b/pdf-over-commons/pom.xml @@ -24,5 +24,14 @@ + + + + src/main/resources + true + + + + \ No newline at end of file diff --git a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Constants.java b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Constants.java index 901d0824..4b6e3c10 100644 --- a/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Constants.java +++ b/pdf-over-commons/src/main/java/at/asit/pdfover/commons/Constants.java @@ -23,6 +23,8 @@ import java.util.Properties; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.widgets.Display; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -30,11 +32,25 @@ import org.eclipse.swt.widgets.Display; */ public class Constants { + static private final Logger log = LoggerFactory.getLogger(Constants.class); + /** Application name */ public static final String APP_NAME = "PDF-Over"; //$NON-NLS-1$ /** Application version */ - public static final String APP_VERSION = Constants.class.getPackage().getImplementationVersion(); + public static final String APP_VERSION; + static + { + String v = null; + try { + Properties props = new Properties(); + props.load(Constants.class.getClassLoader().getResourceAsStream("version.properties")); + v = props.getProperty("version"); + } catch (Exception e) { + log.warn("Failed to load project version", e); + } + APP_VERSION = v; + } /** Application name + version */ public static final String APP_NAME_VERSION = (APP_VERSION == null ? APP_NAME : APP_NAME + " v" + APP_VERSION); //$NON-NLS-1$ diff --git a/pdf-over-commons/src/main/resources/version.properties b/pdf-over-commons/src/main/resources/version.properties new file mode 100644 index 00000000..defbd482 --- /dev/null +++ b/pdf-over-commons/src/main/resources/version.properties @@ -0,0 +1 @@ +version=${project.version} -- cgit v1.2.3