Skip to content

Conversation

@pengdev
Copy link
Member

@pengdev pengdev commented May 2, 2022

For reference: https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing

Starting with Gradle 4.7, the incremental compiler also supports incremental annotation processing. All annotation processors need to opt in to this feature, otherwise they will trigger a full recompilation.

The whole Gradle module will be non-incremental if there is just one non-incremental annotation processor. We need to make sure that all annotation processors in the module support incremental kapt.

This PR adds incremental annotation processing support to ModuleProviderGenerator. More specifically, it makes ModuleProviderGenerator an isolating annotation processor. This PR also introduces https://github.com/tbroyer/gradle-incap-helper as compile dependency to generate the META-INF descriptor.

cc @LukasPaczos @tobrun

@pengdev pengdev force-pushed the peng-support-incremental-processing branch 3 times, most recently from 48c2db5 to c528e6d Compare May 2, 2022 20:47
@pengdev pengdev self-assigned this May 2, 2022
@LukasPaczos LukasPaczos linked an issue May 3, 2022 that may be closed by this pull request
@pengdev pengdev force-pushed the peng-support-incremental-processing branch from c528e6d to 1e2fb84 Compare May 4, 2022 09:58
@pengdev pengdev marked this pull request as ready for review May 4, 2022 09:58
@pengdev pengdev requested a review from LukasPaczos May 4, 2022 09:58
@pengdev
Copy link
Member Author

pengdev commented May 4, 2022

Validated with building examples project and modify the MyLogger class's MapboxModule annotation and see the following output:

[INFO] Kapt3 is enabled (stand-alone mode).
Annotation processing mode: apt
Memory leak detection mode: none
Show processor time: false
Verbose mode: true
Info as warnings: false
Use light analysis: false
Correct error types: false
Dump default parameter values: false
Map diagnostic locations: false
Strict mode: false
Detect annotation processors in compile classpath: true
Incremental annotation processing (apt mode): true
Project base dir: /Users/pengliu/Documents/mapbox-base-android/examples
Compile classpath: 
...
Sources output directory: /Users/pengliu/Documents/mapbox-base-android/examples/build/generated/source/kapt/debug
Class files output directory: /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/classes/debug
Stubs output directory: /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/stubs/debug
Incremental data output directory: /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/stubs/debug
Annotation processing classpath: /Users/pengliu/Documents/mapbox-base-android/annotations-processor/build/libs/annotations-processor-0.7.0-SNAPSHOT.jar, /Users/pengliu/Documents/mapbox-base-android/annotations/build/libs/annotations-0.7.0-SNAPSHOT.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.squareup/kotlinpoet/1.6.0/6ce4c42da0daf2ba11a4180d33360e8c049ef5b8/kotlinpoet-1.6.0.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.72/916d54b9eb6442b615e6f1488978f551c0674720/kotlin-stdlib-jdk8-1.3.72.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.4.10/30e46450b0bb3dbf43898d2f461be4a942784780/kotlin-stdlib-jdk7-1.4.10.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.auto.service/auto-service/1.0-rc7/894e4af172edf98872bf87f5a90912f86f3e9158/auto-service-1.0-rc7.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.1.0/e3a6fb2f40e3a3842e6b7472628ba4ce416ea4c8/annotation-1.1.0.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.3.72/86613e1a669a701b0c660bfd2af4f82a7ae11fca/kotlin-reflect-1.3.72.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.4.10/ea29e063d2bbe695be13e9d044dcfb0c7add398e/kotlin-stdlib-1.4.10.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.auto.service/auto-service-annotations/1.0-rc7/8849037b03b10cd3d71cce67f8b99aed183971cb/auto-service-annotations-1.0-rc7.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.auto/auto-common/0.10/c8f153ebe04a17183480ab4016098055fb474364/auto-common-0.10.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-jre/bd41a290787b5301e63929676d792c507bbc00ae/guava-27.0.1-jre.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.4.10/6229be3465805c99db1142ad75e6c6ddeac0b04c/kotlin-stdlib-common-1.4.10.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.guava/failureaccess/1.0.1/1dcf1de382a0bf95a3d8b0849546c88bac1292c9/failureaccess-1.0.1.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/b421526c5f297295adef1c886e5246c39d4ac629/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-qual/2.5.2/cea74543d5904a30861a61b4643a5f2bb372efc4/checker-qual-2.5.2.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.2.0/88e3c593e9b3586e1c6177f89267da6fc6986f0c/error_prone_annotations-2.2.0.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.1/ed28ded51a8b1c6b112568def5f4b455e6809019/j2objc-annotations-1.1.jar, /Users/pengliu/.gradle/caches/modules-2/files-2.1/org.codehaus.mojo/animal-sniffer-annotations/1.17/f97ce6decaea32b36101e37979f8b647f00681fb/animal-sniffer-annotations-1.17.jar
Annotation processors: 
AP options: {kapt.kotlin.generated=/Users/pengliu/Documents/mapbox-base-android/examples/build/generated/source/kaptKotlin/debug}
Javac options: {-source=1.7}
[incremental apt] Changed files: [/Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/stubs/debug/com/mapbox/common/examples/MyLogger.java]
[incremental apt] Compiled sources directories: /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kotlin-classes/debug, /Users/pengliu/Documents/mapbox-base-android/examples/build/intermediates/javac/debug/classes
[incremental apt] Cache directory for incremental compilation: /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/incApCache/debug
[incremental apt] Changed classpath names: 

[INFO] Need to discovery annotation processors in the AP classpath
[INFO] Annotation processors: com.mapbox.annotation.processor.ModuleProviderGenerator, com.google.auto.service.processor.AutoServiceProcessor
[INFO] Processing java sources with annotation processors: /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/stubs/debug/com/mapbox/common/examples/MyLogger.java, /Users/pengliu/Documents/mapbox-base-android/examples/build/tmp/kapt3/stubs/debug/error/NonExistentClass.java
Note: Generating module configuration class for com.mapbox.common.examples.MyLogger[INFO] Analyzing sources structure took 1[ms].
[INFO] Annotation processing complete, errors: 0, warnings: 0
[INFO] Annotation processor stats:
[INFO] com.mapbox.annotation.processor.ModuleProviderGenerator: total: 120 ms, init: 17 ms, 2 round(s): 103 ms, 0 ms
[INFO] com.google.auto.service.processor.AutoServiceProcessor: total: 4 ms, init: 4 ms, 0 round(s): 
File Object History : []
Open Type Names     : []
Gen. Src Names      : []
Gen. Cls Names      : []
Agg. Gen. Src Names : []
Agg. Gen. Cls Names : []
[INFO] Annotation processing took 155 ms

@pengdev pengdev merged commit f7e4766 into master May 4, 2022
@pengdev pengdev deleted the peng-support-incremental-processing branch May 4, 2022 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verify incremental annotation processing

3 participants