allprojects { afterEvaluate { extensions.findByName('kapt')?.arguments { arg("dagger.formatGeneratedSource", "disabled") arg("dagger.gradle.incremental", "enabled") } } }
kapt { arguments { arg('dagger.formatGeneratedSource', 'disabled') arg('dagger.gradle.incremental', 'enabled') } }
@Inject @field:MinimumBalance lateinit var minimumBalance: BigDecimal
@Inject @MinimumBalance lateinit var minimumBalance: BigDecimal // @MinimumBalance is ignored!
@Module object NetworkModule { @JvmStatic @Provides fun provideOkHttpClient(): OkHttpClient { return OkHttpClient.Builder().build() } }
@Module abstract class NetworkModule { @Binds abstract fun provideService(retrofitService: RetrofitService): Service @Module companion object { @JvmStatic @Provides fun provideOkHttpClient(): OkHttpClient { return return OkHttpClient.Builder().build() } } }
@Module(includes = [OkHttpClientModule::java]) abstract class NetworkModule { @Binds abstract fun provideService(retrofitService: RetrofitService): Service } @Module object OkHttpClientModule { @JvmStatic @Provides fun provideOkHttpClient(): OkHttpClient { return OkHttpClient.Builder().build() } }
class MyVMFactory @Inject constructor( private val vmMap: Map<String, @JvmSuppressWildcards Provider<ViewModel>> ) { ... }
@Provides fun provideNetworkPrinter() = NetworkPrinter() @Provides fun provideNetworkPrinter(): NetworkPrinter = NetworkPrinter() @Provides fun provideNetworkPrinter(): NetworkPrinter { return NetworkPrinter() }
@Provides // configures a `Printer` fun providePrinter(): Printer = NetworkPrinter() @Provides // configures a `NetworkPrinter`, not a plain `Printer`! fun providePrinter() = NetworkPrinter()