parceler
parceler copied to clipboard
Fields on parceler breaks Incremental annotation processor.
Hi, i found some cases where parceler breaks the incremental compilation. I have sample project for this issue:
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:
- Unzip and open the project.
- Run clean build (./gradlew clean app:assembleD)
- 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(){
//
// }
}
-
Run the project and print the compiled class during kapt process with this command:
./gradlew app:assembleD --debug --Pkapt.verbose=true > log1.txt -
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. -
Change BaseClassParcel field to private
public class BaseClassParcel {
//it working fine if private, but protected will cause all files recompiled
private FieldClassParcel testField;
}
- 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.
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.
Hmm, any ideas on a fix?
I manage to fix this by moving affected class into the same module, or change the field into public (instead protected).