Since there are no direct answers to this, did a bit of research and came across this PR.
https://github.com/jacoco/jacoco/pull/822/files
private static boolean matches(final String annotation) {
final String name = annotation
.substring(Math.max(annotation.lastIndexOf('/'),
annotation.lastIndexOf('$')) + 1);
return name.contains("Generated")
}
You can create any annotation with name containing "Generated". I've created the following in my codebase to exclude methods from being included in Jacoco report.
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface ExcludeFromJacocoGeneratedReport {}
Use this annotation in your methods to exempt it from coverage as below.
public class Something
{
@ExcludeFromJacocoGeneratedReport
public void someMethod() {}
}
@ExcludeFromGeneratedCodeCoverage
would do :D – Profanatory