parceler icon indicating copy to clipboard operation
parceler copied to clipboard

Fields on parceler breaks Incremental annotation processor.

Open doniwinata0309 opened this issue 6 years ago • 3 comments

Hi, i found some cases where parceler breaks the incremental compilation. I have sample project for this issue:

Parceler-test.zip

There are 3 modules: app (application module), depends to: basemodule and mylibrary1.

Supposed on basemodule we have these:

package com.test.basemodule;

import org.parceler.Parcel;

@Parcel
public class FieldClassParcel {
}

and


import org.parceler.Parcel;

@Parcel
public class BaseClassParcel {
    //it working fine if private, but protected will cause all files recompiled
    protected FieldClassParcel testField;
}

Those two class used on app module:

public class ExampleParcel extends BaseClassParcel {

    private final String message;

    @ParcelFactory
    public static ExampleParcel create(String message) {
        return new ExampleParcel(message);
    }

    public ExampleParcel(String message) {
        this.message = message;
    }

    public String getMessage(){
        return message;
    }
}

Those classes will breaks incremental annotation processor on app module.

Step to repro:

  1. Unzip and open the project.
  2. Run clean build (./gradlew clean app:assembleD)
  3. Change public ABI on LibClass.java
    public void method1changed2(){

    }
    //uncomment this for test public ABI change (incremental), or change the method name `method1`)

//    public void method2(){
//
//    }
}
  1. Run the project and print the compiled class during kapt process with this command: ./gradlew app:assembleD --debug --Pkapt.verbose=true > log1.txt

  2. The result should be similar with file: incremental-test1.txt on attached file. the part i: [kapt] Java source files: on module app should contains lot of files.

  3. Change BaseClassParcel field to private

public class BaseClassParcel {
    //it working fine if private, but protected will cause all files recompiled
    private FieldClassParcel testField;
}
  1. clean the project, and repeat step 1-5. The result of this test will be similar to incremental-test2.txt. the part i: [kapt] Java source files: should be empty in this test.

The files that recompile will be all java source file in the module, including another annotation processor. For a module with large annotated files it taking so long to build.

Hopefully this is clear enough to explain our issue, let me know if you need additional information. Thanks.

doniwinata0309 avatar Oct 02 '19 09:10 doniwinata0309

I also reporting here: https://youtrack.jetbrains.com/issue/KT-34340 we can use kotlin 1.3.70 to spot the files that causing full recompilation.

Seems to be those classes always extending the class from another module, and generating: $$PackageHelper. This fails the incremental compilation.

doniwinata0309 avatar Oct 24 '19 07:10 doniwinata0309

Hmm, any ideas on a fix?

johncarl81 avatar Oct 24 '19 18:10 johncarl81

I manage to fix this by moving affected class into the same module, or change the field into public (instead protected).

doniwinata0309 avatar Oct 30 '19 09:10 doniwinata0309