From da8b893e6fc024b7d9f5ed1fc7632138dcd129e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 2 Mar 2019 20:55:24 +0100 Subject: [PATCH] =?utf8?q?=E2=AC=86=EF=B8=8F=20Update=20Guice=20to=204.2.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt | 7 ++++--- src/test/kotlin/net/pterodactylus/sone/test/Guice.kt | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 7e5604f..1cee731 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ dependencies { compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib' compile group: 'net.pterodactylus', name: 'utils', version: '0.12.4' - compile group: 'com.google.inject', name: 'guice', version: '3.0' + compile group: 'com.google.inject', name: 'guice', version: '4.2.2' compile group: 'com.google.guava', name: 'guava', version: '27.0.1-android' compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.1' compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.1' diff --git a/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt index a8da595..1253d0a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/FreenetModule.kt @@ -6,6 +6,7 @@ import com.google.inject.Provides import freenet.client.HighLevelSimpleClient import freenet.node.Node import freenet.pluginmanager.PluginRespirator +import javax.inject.Provider import javax.inject.Singleton /** @@ -14,9 +15,9 @@ import javax.inject.Singleton class FreenetModule(private val pluginRespirator: PluginRespirator): Module { override fun configure(binder: Binder): Unit = binder.run { - bind(PluginRespirator::class.java).toProvider { pluginRespirator } - pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider { node } } - bind(HighLevelSimpleClient::class.java).toProvider { pluginRespirator.hlSimpleClient!! } + bind(PluginRespirator::class.java).toProvider(Provider { pluginRespirator }) + pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider(Provider { node }) } + bind(HighLevelSimpleClient::class.java).toProvider(Provider { pluginRespirator.hlSimpleClient!! }) } @Provides @Singleton diff --git a/src/test/kotlin/net/pterodactylus/sone/test/Guice.kt b/src/test/kotlin/net/pterodactylus/sone/test/Guice.kt index f9119c3..360b0cd 100644 --- a/src/test/kotlin/net/pterodactylus/sone/test/Guice.kt +++ b/src/test/kotlin/net/pterodactylus/sone/test/Guice.kt @@ -5,16 +5,16 @@ import com.google.inject.Module import javax.inject.Provider import kotlin.reflect.KClass -fun KClass.isProvidedBy(instance: T) = Module { it.bind(this.java).toProvider { instance } } +fun KClass.isProvidedBy(instance: T) = Module { it.bind(this.java).toProvider(Provider { instance }) } fun KClass.isProvidedBy(provider: com.google.inject.Provider) = Module { it.bind(this.java).toProvider(provider) } fun KClass.isProvidedBy(provider: KClass>) = Module { it.bind(this.java).toProvider(provider.java) } -inline fun KClass.isProvidedByMock() = Module { it.bind(this.java).toProvider { mock() } } +inline fun KClass.isProvidedByMock() = Module { it.bind(this.java).toProvider(Provider { mock() }) } inline fun Injector.getInstance() = getInstance(T::class.java)!! fun supply(javaClass: Class): Source = object : Source { override fun fromInstance(instance: T) = Module { it.bind(javaClass).toInstance(instance) } - override fun byInstance(instance: T) = Module { it.bind(javaClass).toProvider { instance } } + override fun byInstance(instance: T) = Module { it.bind(javaClass).toProvider(Provider { instance }) } override fun byProvider(provider: com.google.inject.Provider) = Module { it.bind(javaClass).toProvider(provider) } override fun byProvider(provider: Class>) = Module { it.bind(javaClass).toProvider(provider) } } -- 2.7.4