Class GeneratedAnnotationScanner

java.lang.Object
com.arc_e_tect.gradle.jacoco.scan.GeneratedAnnotationScanner

public class GeneratedAnnotationScanner extends Object
Scans a compiled .class file for members that JaCoCo automatically excludes from coverage because they carry an annotation whose simple name is Generated — the same convention JaCoCo itself relies on since version 0.8.2.

This covers code synthesised by another tool that stamps its output with such an annotation, most notably Lombok's @lombok.Generated on every getter, setter, constructor, equals/hashCode/ toString, and builder method it generates. These members never exist in the .java source, so — unlike AnnotationScanner — this scanner reads bytecode rather than parsing source.

  • Constructor Details

    • GeneratedAnnotationScanner

      public GeneratedAnnotationScanner()
  • Method Details

    • scan

      public List<ExcludedElement> scan(File classFile) throws IOException
      Scans one .class file and returns every member carrying a Generated-named annotation.
      Parameters:
      classFile - the compiled class file to inspect
      Returns:
      possibly-empty list of excluded elements, never null
      Throws:
      IOException - if the file cannot be read or is not a valid class file