Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking if kapt uses incremental annotation processing

In Kotlin 1.3.30 support for incremental annotation processing was added: https://blog.jetbrains.com/kotlin/2019/04/kotlin-1-3-30-released/ According to the doc:

Note that in the current implementation, using any non-incremental annotation processor or a change in dependency’s ABI (so far, including modifying internal declarations) will lead to non-incremental annotation processing for a given module.

I have a multi-module project with multiple annotation processors. Only some of them are incremental. There are modules which use only incremental annotation processors to the best of my knowledge at least.

My question is: Is there a way to check if incremental annotation processing happened? E.g. are there any specific console logs in Gradle which indicate that? I would like to confirm that incremental annotation processing was in fact used.

like image 206
Piotr Zawadzki Avatar asked May 14 '19 14:05

Piotr Zawadzki


1 Answers

I was able to determine that by adding

kapt.verbose=true

in gradle.properties in root project. This leads to the following being printed in the console when e.g. changing public methods:

Javac options: {}
[incremental apt] Changed files: [/Users/me/workspace/my-project/core/common/build/tmp/kapt3/stubs/foo/bar/ChangedClassName.java]
...
[INFO] Need to discovery annotation processors in the AP classpath
[INFO] Annotation processors: toothpick.compiler.factory.FactoryProcessor, toothpick.compiler.memberinjector.MemberInjectorProcessor
[INFO] Processing java sources with annotation processors: /Users/me/workspace/my-project/core/common/build/tmp/kapt3/stubs/foo/bar/ChangedClassName.java
[INFO] Annotation processing complete, errors: 0, warnings: 0
[INFO] Annotation processor stats:
[INFO] IncrementalProcessor: total: 61 ms, init: 1 ms, 3 round(s): 59 ms, 0 ms, 1 ms
[INFO] IncrementalProcessor: total: 1 ms, init: 1 ms, 3 round(s): 0 ms, 0 ms, 0 ms

This is when incremental annotation processing was used. When doing a clean build this prints:

Javac options: {}
[incremental apt] Changed files: []
...
[INFO] Need to discovery annotation processors in the AP classpath
[INFO] Annotation processors: toothpick.compiler.factory.FactoryProcessor, toothpick.compiler.memberinjector.MemberInjectorProcessor
[INFO] Processing java sources with annotation processors: [ALL THE  FILES IN THE MODULE ARE LISTED HERE]
[INFO] Annotation processing complete, errors: 0, warnings: 0
[INFO] Annotation processor stats:
[INFO] IncrementalProcessor: total: 124 ms, init: 1 ms, 3 round(s): 122 ms, 1 ms, 0 ms
[INFO] IncrementalProcessor: total: 1 ms, init: 0 ms, 3 round(s): 1 ms, 0 ms, 0 ms

Toothpick is a DI framework I'm using, which since 2.x supports incremental annotation processing.

If there's an annotation processor which is not incremental this also prints e.g.:

[INFO] Incremental KAPT support is disabled. Processors that are not incremental: butterknife.compiler.ButterKnifeProcessor.
like image 101
Piotr Zawadzki Avatar answered Sep 30 '22 08:09

Piotr Zawadzki