square / anvil

A Kotlin compiler plugin to make dependency injection with Dagger 2 easier.
Apache License 2.0
1.3k stars 79 forks source link

binding extension properties to Gradle properties #851

Closed RBusarow closed 7 months ago

RBusarow commented 7 months ago

This change makes it so that all of Anvil's existing configuration options can be set via a gradle.properties or a -P_______ command line option.

For any setting, Anvil take the first non-null value out of:

  1. Settings in the Gradle DSL:
    anvil {
     generateDaggerFactories.set(true)
    }
  2. Properties set via the command line like:
    ./gradlew build -Pcom.squareup.anvil.generateDaggerFactories=true
  3. Properties specified in a project-level, root-project-level, or ~/.gradle/-level gradle.properties:
    com.squareup.anvil.generateDaggerFactories = true
  4. Hard-coded default values (never null)

Practically speaking, this makes it possible to locally feature-toggle things (like the upcoming incremental fix) without touching a project's build logic.