Download Latest Version v0.8.0 source code.tar.gz (178.9 kB)
Email in envelope

Get an email when there's a new version of kotlin-inject

Home / v0.7.0
Name Modified Size InfoDownloads / Week
Parent folder
0.7.0 source code.tar.gz 2024-06-12 170.8 kB
0.7.0 source code.zip 2024-06-12 290.9 kB
README.md 2024-06-12 2.6 kB
Totals: 3 Items   464.3 kB 0

[0.7.0] 2024-06-12

Changed

  • @Scope annotations now take arguments into account. This means for example, if you have kotlin @Scope annotation class NamedScope(val value: String) then the scope: @NamedScope("one") and @NamedScope("two") would be treated as distinct. Previously they were treated as the same scope.
  • Legacy implicit assisted injection (not using the @Assisted annotation) is now an error.
  • The build will now fail if multiple qualifiers are applied in the same place, instead of picking the first one. This applies both to the new annotation (see below) and javax.inject.Qualifier. A minor exception is you are allowed to have one of each type to aid in migration. In that case the me.tatarka.inject one will be chosen.

Added

  • Added a me.tatarka.inject.annotations.Qualifier annotation as an alternative to using typealias. For example, you could do: ```kotlin @Qualifier annotation class Named(val value: String)

@Inject class MyClass(@Named("one") val one: String, @Named("two") val two: String)

@Component abstract class MyComponent { abstract val myClass: MyClass

@Provides @Named("one")
fun provideOne(): String = "one"

@Provides @Named("two")
fun provideTwo(): String = "two"

} This behaves the same as `javax.inject.Qualifier` does when you have `me.tatarka.inject.enableJavaxAnnotations=true`. - Added a new `@KmpComponentCreate` annotation for nicer multiplatform support. This allows you to create component instances from common code when generating platform-specific outputs.kotlin // src/commonMain @Component abstract class MyKmpComponent

@KmpComponentCreate expect fun createKmp(): MyKmpComponent see the new [multiplatform docs](docs/multiplatform.md) for more details. - You can now use an `@Inject` annotation on an inner class provided the outer class can be provided.kotlin @Inject class Outer { @Inject inner class Inner }

@Component abstract class MyComponent { abstract val inner: Outer.Inner } ```

Removed

  • The KAPT backend is removed, please migrate to KSP if you haven't already.

Fixed

  • Fixed cases of invalid code generation (#321, [#337], [#313]).
  • Fixed an exception thrown on KSP2 when running multiple rounds (google/ksp#1854).
  • Fixed various issues with handling method overrides in components (#309, [#375])
  • Allow scope annotations on both an interface and component implementation if they are the same scope (#320).
Source: README.md, updated 2024-06-12