AnvilExtension

abstract class AnvilExtension @Inject constructor(objects: ObjectFactory)

Functions

variantFilter
Link copied to clipboard
fun variantFilter(action: Action<VariantFilter>)

Configures each variant of this project. For Android projects these are the respective Android variants, for JVM projects these are usually the main and test variant.

Properties

disableComponentMerging
Link copied to clipboard
val disableComponentMerging: Property<Boolean>

Enabling this indicates that only code generation should run and no component merging should run. This is useful for cases where you want to use @ContributesTo, @ContributesBinding, or similar annotations but not@MergeComponent or @MergeSubcomponent functionality. This allows for anvil use in projects with kapt enabled but not require disabling incremental compilation in kapt stub generation tasks.

disableComponentMergingLegacy
Link copied to clipboard
@get:JvmName(name = "getDisableComponentMerging")
@set:JvmName(name = "setDisableComponentMerging")
var disableComponentMergingLegacy: Boolean
generateDaggerFactories
Link copied to clipboard
val generateDaggerFactories: Property<Boolean>

Allows you to use Anvil to generate Factory classes that usually the Dagger annotation processor would generate for @Provides methods, @Inject constructors and @Inject fields.

generateDaggerFactoriesLegacy
Link copied to clipboard
@get:JvmName(name = "getGenerateDaggerFactories")
@set:JvmName(name = "setGenerateDaggerFactories")
var generateDaggerFactoriesLegacy: Boolean
generateDaggerFactoriesOnly
Link copied to clipboard
val generateDaggerFactoriesOnly: Property<Boolean>

There are occasions where consumers of Anvil are only interested in generating Dagger factories to speed up build times and don't want to make use of the other features. With this flag Anvil will only generate Dagger factories and skip all other steps. If this flag is set to true, then also generateDaggerFactories must be set to true.

generateDaggerFactoriesOnlyLegacy
Link copied to clipboard
@get:JvmName(name = "getDaggerFactoriesOnly")
@set:JvmName(name = "setDaggerFactoriesOnly")
var generateDaggerFactoriesOnlyLegacy: Boolean