jakartaee / common-annotations-api

Jakarta Annotations
https://eclipse.org/ee4j/ca
Other
51 stars 38 forks source link

Generated scoping issue #103

Open ghulands opened 2 years ago

ghulands commented 2 years ago

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.

christianhujer commented 1 year ago

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.

xenoterracide commented 1 month ago

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

https://github.com/spotbugs/spotbugs/issues/1385#issuecomment-2263928392