Skip to content

Incremental compilation breaks when modifying constructor properties #754

@Laimiux

Description

@Laimiux

What

Incremental builds consistently fail to compile after adding or removing constructor parameters to a class marked with @ContributesBinding. I was able to reproduce it with some slight modifications to the sample within the Anvil repo

  • Checkout the branch or copy code over link.
  • First run ./gradlew :sample:assembleDebug
  • Add or remove a parameter within RealParents class
  • Run ./gradlew :sample:assembleDebug again
  • You should see an error
/Users/laimonasturauskas/android/anvil/sample/app/build/tmp/kapt3/stubs/debug/com/squareup/anvil/sample/AppComponent.java:7: error: [Dagger/MissingBinding] com.squareup.anvil.sample.Parents cannot be provided without an @Provides-annotated method.
public abstract interface AppComponent extends com.squareup.anvil.sample.RandomComponent, com.squareup.anvil.sample.DescriptionComponent {
                ^
  
  Missing binding usage:
      com.squareup.anvil.sample.Parents is requested at
          com.squareup.anvil.sample.DescriptionComponent.parents()

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sample:app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask$KaptExecutionWorkAction
   > java.lang.reflect.InvocationTargetException (no error message)

The issue goes away when running ./gradlew :sample:asDebug --rerun-tasks. One potential hint is that the library/build/anvil/src-gen-main/ folder to be empty after incremental build compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions