Skip to content

0.7.0

Compare
Choose a tag to compare
@evant evant released this 12 Jun 22:07
· 35 commits to main since this release

[0.7.0] 2024-06-12

Changed

  • @Scope annotations now take arguments into account. This means for example, if you have
    @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:
    @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.
    // src/commonMain
    @Component
    abstract class MyKmpComponent
     
    @KmpComponentCreate
    expect fun createKmp(): MyKmpComponent
    see the new multiplatform docs for more details.
  • You can now use an @Inject annotation on an inner class provided the outer class can be provided.
    @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).