From e4bd9c71422dc24bacc7970f270880725bc7ee4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 7 Oct 2017 16:49:42 +0200 Subject: [PATCH] Use generated version as plugin version --- src/main/java/net/pterodactylus/sone/main/SonePlugin.java | 10 ++++------ src/main/kotlin/net/pterodactylus/sone/main/VersionParser.kt | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index f394d44..60e4292 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -114,9 +114,6 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr }); } - /** The version. */ - private static final Version VERSION = new Version(0, 9, 6); - /** The current year at time of release. */ private static final int YEAR = 2016; private static final String SONE_HOMEPAGE = "USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/"; @@ -175,7 +172,8 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr } public static String getPluginVersion() { - return VERSION.toString(); + net.pterodactylus.sone.main.Version version = VersionParserKt.parseVersion(); + return (version == null) ? "unknown" : version.getNice(); } public static int getYear() { @@ -250,7 +248,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr bind(Context.class).toInstance(context); bind(getOptionalContextTypeLiteral()).toInstance(of(context)); bind(SonePlugin.class).toInstance(SonePlugin.this); - bind(Version.class).toInstance(VERSION); + bind(Version.class).toInstance(Version.parse(getVersion())); bind(PluginVersion.class).toInstance(new PluginVersion(getVersion())); bind(PluginYear.class).toInstance(new PluginYear(getYear())); bind(PluginHomepage.class).toInstance(new PluginHomepage(getHomepage())); @@ -404,7 +402,7 @@ public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr */ @Override public String getVersion() { - return VERSION.toString(); + return getPluginVersion(); } public static class PluginVersion { diff --git a/src/main/kotlin/net/pterodactylus/sone/main/VersionParser.kt b/src/main/kotlin/net/pterodactylus/sone/main/VersionParser.kt index cb79893..09e91bd 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/VersionParser.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/VersionParser.kt @@ -3,6 +3,7 @@ package net.pterodactylus.sone.main import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.dataformat.yaml.YAMLFactory +@JvmOverloads fun parseVersion(file: String = "/version.yaml"): Version? = Version::class.java.getResourceAsStream(file)?.use { objectMapper.readValue(it, Version::class.java) -- 2.7.4