autonomousapps / autonomousapps/dependency-analysis-gradle-plugin
AnnotationProcessor detection fails to collect all supported annotation types when multiple annotation processors exist in the same artifact/coordinate
- Dominant language
- Kotlin
- Stars
- 2.2k
- Forks
- 158
- Avg merge
- 16h 25m
- Merged PRs (30d)
- 46
Description
**Build scan link**
n/a
**Plugin version**
1.18.0
**Gradle version**
7.7
**(Optional) Android Gradle Plugin (AGP) version**
n/a
**`reason` output for bugs relating to incorrect advice**
n/a
**Describe the bug**
When annotation processor dependencies are examined, a list of supported annotation types is found and assigned to an AnnotationProcessorDependency object for a specific coordinate. When multiple annotation processors are available in the artifact found for a given coordinate, only the supported annotations types from the last discovered annotation processor are saved. All other annotations processors are then marked as not needed during evaluation because their lists of supported annotation types were accidentally discarded.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a jar that contains two annotation processors and lists them in src\main\resources\META-INF\services\javax.annotation.processing.Processor
2. Create a project that uses annotations from the first processor listed in the processor metadata but do not include annotations from the second processor.
3. projectHealth indicates that the annotation processor is unused.
**Expected behavior**
If any of the supported annotation types from any of the annotation processors included in a dependency are used, then the dependency is considered as 'used'.
**Additional context**
n/a
Contributor guide
Research direction
Start by reproducing the issue with a JAR containing two annotation processors listed in META-INF/services/javax.annotation.processing.Processor, then inspect how supported annotation types are collected for one dependency coordinate. Verify the fix by confirming that using annotations from either processor keeps the dependency marked as used, while unused processors are still identified correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100