kosi-libs / Kodein

Painless Kotlin Dependency Injection

Home Page:https://kosi-libs.org/kodein

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kodein Plugin Does Not Work With Ktor 2.0

AlexandreBrown opened this issue · comments

Describe the bug
Some breaking changes were introduced in ktor 2.0.
Ktor "features" were renamed to "plugins" and this causes Kodein Feature to be incompatible with Ktor 2.0.
More information about this change can be found here.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Ktor 2.0 project
  2. Add Kodein ktor dependency : implementation("org.kodein.di:kodein-di-framework-ktor-server-jvm:7.9.0)
  3. Try to install the DIFeature Plugin
import io.ktor.server.application.Application
import org.kodein.di.ktor.DIFeature

fun Application.installPlugins() {
	install(DIFeature)
}
  1. See error, the Kodein Plugin cannot be installed.
    image
Type mismatch.
    Required:
        Plugin<TypeVariable(P), TypeVariable(B), TypeVariable(F)>
    Found:
        DIFeature.Feature

Expected behavior
The Kodein Plugin can be installed.

Kodein project used and used version:
org.kodein.di:kodein-di-framework-ktor-server-jvm version 7.9.0

Additional moduleDefinition
io.ktor:ktor-server-core:2.0.0-beta-1

Actually, it does, but not in the stable channel, because Ktor 2.0 is not stable yet.
I did publish a version compatible with Ktor 2.0 EAP few weeks ago.
It's available on maven central snapshot repository.
I will build a new version ASAP based on the beta-1.

Hi, you can find a snapshot version working with Ktor 2.0 beta 1.

You will find it on the repo
https://s01.oss.sonatype.org/content/repositories/snapshots/
under the version 8.0.0-ktor-2-beta1-SNAPSHOT.

I bumped the version as it includes breaking changes with Ktor refactoring.
Let me know if this helps.