Annotate generated classes with Generated
annotation which has retention policy CLASS
or RUNTIME
#142
Labels
documentation
Improvements or additions to documentation
Currently McJava annotates only classes that are nested under messages. We use
javax.annotation.Generated
.We need to introduce our annotation
io.spine.annotation.Generated
and apply it to the generated code.Here are the reasons.
The state of annotations in the code produced by Protobuf and gRPC
The top level classes created by
protoc
have comments about the generated nature of the code... but they are not annotated by
protoc
, and we do not add the annotation by McJava either.gRPC plugin for
protoc
does annotate the generated classes usingjavax.annotation.Generated
. For example, here's howCommandServiceGrpc
annotation looks like:Even though gRPC authors use
javax.annotation.Generated
annotation they intend to introduce their own.Generated code, annotations and test coverage
Our projects tune JaCoCo and Codecov to exclude files under the
generated
directory from the reports.Spine users will need to apply similar tweaks to their projects to get more accurate test coverage reports.
JaCoCo analyses Java classes for the presence of an annotation which simple name is
Generated
. It cannot beGrpcGenerated
orSpineGenerated
. It could be any package, but the simple name must beGenerated
. Such a class is automatically excluded from the report.The problem with
javax.annotation.Generated
is that its retention level isSOURCE
. JaCoCo needs eitherCLASS
orRUNTIME
retention. It does not deal with the source code parsing.Our actions
io.spine.annotation.Generated
inbase
. UseCLASS
retention level.io.spine.annotations.Generated
in the code produced by McJava.Generated
annotation on the Java code elements it creates, and apply theio.spine.annotation.Modified
annotation on the code elements it modifies.Generated
annotation to Protobuf-generated code. Refer to Protobuf compiler in the annotation parameters using version of theprotoc
we use.comments
property of the annotation.javax.annotation.Generated
withio.spine.annotation.Generated
in the code generated by gRPC. This is to exclude this code from test coverage reports. We also need to add a reference to the document explaining the matter.The text was updated successfully, but these errors were encountered: