From 562aaadc1d11a79f467189cff0a95a7d19d56e51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 10 Jul 2019 21:39:12 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=90=9B=20Fix=20version=20parsing=20in=20So?= =?utf8?q?neModule?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- build.gradle | 6 +++--- src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt | 2 +- src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt | 8 +++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 0beb42a..dc7878c 100644 --- a/build.gradle +++ b/build.gradle @@ -20,8 +20,8 @@ repositories { apply plugin: 'java' -sourceCompatibility = 1.7 -targetCompatibility = 1.7 +sourceCompatibility = 1.8 +targetCompatibility = 1.8 tasks.withType(JavaCompile) { options.encoding = 'UTF-8' @@ -43,7 +43,7 @@ dependencies { provided group: 'org.freenetproject', name: 'freenet-ext', version: '29' provided group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.54' - compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib' + compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8' compile group: 'net.pterodactylus', name: 'utils', version: '0.12.4' compile group: 'com.google.inject', name: 'guice', version: '4.2.2' compile group: 'com.google.guava', name: 'guava', version: '27.0.1-android' diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index a3fe9be..6a349eb 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -44,7 +44,7 @@ class SoneModule(private val sonePlugin: SonePlugin) : AbstractModule() { bind(Context::class.java).toInstance(context) bind(object : TypeLiteral>() {}).toInstance(Optional.of(context)) bind(SonePlugin::class.java).toInstance(sonePlugin) - bind(Version::class.java).toInstance(sonePlugin.version.parseVersion()) + bind(Version::class.java).toInstance(sonePlugin.version.drop(1).parseVersion()) bind(PluginVersion::class.java).toInstance(PluginVersion(sonePlugin.version)) bind(PluginYear::class.java).toInstance(PluginYear(sonePlugin.year)) bind(PluginHomepage::class.java).toInstance(PluginHomepage(sonePlugin.homepage)) diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 83d3535..62f947c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -16,14 +16,16 @@ import org.junit.* import java.io.* import java.util.concurrent.atomic.* +const val versionString = "v80" + class SoneModuleTest { private val currentDir: File = File(".") - private val pluginVersion = Version("", 0, 1, 2) + private val pluginVersion = Version("", 80) private val pluginYear = 2019 private val pluginHomepage = "home://page" private val sonePlugin = mock().apply { - whenever(version).thenReturn(pluginVersion.toString()) + whenever(version).thenReturn(versionString) whenever(year).thenReturn(pluginYear) whenever(homepage).thenReturn(pluginHomepage) } @@ -113,7 +115,7 @@ class SoneModuleTest { @Test fun `plugin version is bound`() { - assertThat(injector.getInstance(), equalTo(PluginVersion(pluginVersion.toString()))) + assertThat(injector.getInstance(), equalTo(PluginVersion(versionString))) } @Test -- 2.7.4