AnvilContext

interface AnvilContext

Contains context about the given Anvil compiler invocation. Considered a read-only API.

These loosely correspond to the Anvil Gradle plugin's options, but we may add other information in the future.

Properties

disableComponentMerging
Link copied to clipboard
abstract val disableComponentMerging: 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.

generateFactories
Link copied to clipboard
abstract val generateFactories: 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.

generateFactoriesOnly
Link copied to clipboard
abstract val generateFactoriesOnly: 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.