Reads version of export plugin from pom.xml closes #99
Change-Id: I6aca6e5c740bf208db1ef7c4747fb4e9c6f3796e
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java b/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
index ec1886a..9caace7 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/ExWSConf.java
@@ -16,16 +16,35 @@
public class ExWSConf {
// Version of Export Plugin
- public static final int VERSION_MAJOR = 0;
- public static final int VERSION_MINOR = 2;
- public static final int VERSION_PATCHLEVEL = 7;
+ private static String VERSION;
private static Properties prop;
+ /*
+ * Returns version of the Export Plugin
+ */
+ public static String version(){
+ if (VERSION != null){
+ return VERSION;
+ }
+ else
+ {
+ Properties projProp = new Properties();
+ try{
+ projProp.load(ExWSConf.class.getClassLoader().getResourceAsStream("project.properties"));
+ }
+ catch(Exception e){
+ Logger.error("Unable to load project properties");
+ return null;
+ }
+ VERSION = projProp.getProperty("version");
+ return VERSION;
+ }
+ }
// Load properties from file
public static Properties properties (String propFile) {
- if (prop != null)
+ if (prop != null)
return prop;
if (propFile == null)
@@ -34,7 +53,7 @@
InputStream iFile;
try {
- iFile = new FileInputStream(propFile);
+ iFile = new FileInputStream(propFile);
prop = new Properties();
prop.load(
new BufferedReader(
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java b/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
index 6a7f279..62828a4 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
@@ -2,6 +2,8 @@
import java.util.Properties;
+import org.tinylog.Logger;
+
import java.nio.charset.*;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
@@ -214,8 +216,7 @@
if (this.getMeta() != null && this.getMeta().has("version")) {
this.addInfoRow(w, "Backend-Version", this.getMeta().get("version").asText());
};
-
- this.addInfoRow(w, "Export-Version", this.getVersion().toString());
+ this.addInfoRow(w, "Export-Version", ExWSConf.version());
};
@@ -247,22 +248,6 @@
/*
- * Get version of the plugin
- * (maybe read from pom?)
- */
- private Version getVersion () {
- return new Version(
- ExWSConf.VERSION_MAJOR,
- ExWSConf.VERSION_MINOR,
- ExWSConf.VERSION_PATCHLEVEL,
- null,
- null,
- null
- );
- };
-
-
- /*
* Convert a string to RTF compliant encoding.
*
* Based on jrtf by Christian Ullenboom
diff --git a/src/main/resources/project.properties b/src/main/resources/project.properties
new file mode 100644
index 0000000..e5683df
--- /dev/null
+++ b/src/main/resources/project.properties
@@ -0,0 +1 @@
+version=${project.version}
\ No newline at end of file