autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.75k stars 117 forks source link

AnnotationProcessor detection fails to collect all supported annotation types when multiple annotation processors exist in the same artifact/coordinate #853

Open marklundbergcrd opened 1 year ago

marklundbergcrd commented 1 year ago

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

autonomousapps commented 1 year ago

Thanks for the issue. It would help a lot if you provided a minimal reproducer project, or at the very least indicated an existing library that has multiple annotation processors.