jakartaee/common-annotations-api

Generated scoping issue

Opened this issue · 2 comments

When using generating JAXB classes using the latest xjc with the -mark-generated argument, it generates the classes with the jakarta.annotation.Generated annotation. I have the generated sources in the build folder, but also have sources in the same package as what xjc generates to, so when using Jacoco I can't exclude solely based on package name. Jacoco can automatically exclude a class from reports if it has a @generated annotation. Because the current scoping of the annotation is to SOURCE, jacoco doesn't see it and thus includes the classes in the report.

I'll submit a PR, but thought I would create the issue as well for any discussion.

I second this. It would be great if the Retention would be changed to Runtime. That something is generated isn't just useful information for the source code itself, but also for the byte code and at runtime. And it's a bit of a bummer that the two provided annotations javax.annotations.Generated and jakarta.annotations.Generated can't be used in situations where this type of information is required at runtime.

The same problem exists for spotbugs (comments in thread on related issue (yes they're mentioning javax, but still))

spotbugs/spotbugs#1385 (comment)