Allow custom annotations on generated class files
Closed this issue · 4 comments
I am using jacoco to measure the test coverage in my projects.
Jacoco excludes classes from analysis that have a @Generated
annotation with a retention of at least CLASS
. The package of the annotation does not matter. Just the name and the retention.
I suggest that we add the possibility to annotate classes generated by rocker like this.
I see the following three options:
Rocker provides its own annotation
Create an @com.fizzed.rocker.Generated
annotation and add that to all generated classes.
The user already has to include a rocker runtime dependency. Alternatively rocker could emit the source for the annotation as part of it's source generation.
Rocker uses an established annotation
Rocker could provide support for some established @Generated
annotations. AFAIK there are none. Rocker could also try some fancy classpath scanning and search for @Generated
annotations.
Rocker provides a facillity to let the user provide its own Annotation(s)
Rocker could provide the user with an option to let them specify (a list) of annotations to add. This way each project could provide its own @Generated
annotation or reuse a third party @Generated
annotation if they so desire.
@jjlauer and others,
what do you think? I would be willing to work on a PR. Which option do you prefer?
Edit:
I tried to add my own @Generated
annotation via post-processing. Sadly the template model does not seem to expose the possibility to add annotations.
I just noticed that I did not write which solution I prefer.
I would be in favor Solution 1 (Rocker provides its own annotation) where Rocker provides the annotation in its runtime.
The @javax.annotation.Generated
option was added a while ago and subsequently removed because it is part of a broken jigsaw module. If you wanted to add it back (not using the javax annotation but a custom rocker one), you would add it here:
I'm sure a PR would be accepted if you opened it.