# Grpc maven plugin: annotate generated classes

**URL:** <https://discuss.akka.io/t/grpc-maven-plugin-annotate-generated-classes/9610>\
**Category:** Akka gRPC\
**Created:** [March 16, 2022, 10:46am UTC](https://discuss.akka.io/t/grpc-maven-plugin-annotate-generated-classes/9610 "2022-03-16T10:46:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigurd](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sigurd](https://discuss.akka.io/u/sigurd)\
**Post date:** [March 16, 2022, 10:46am UTC](https://discuss.akka.io/t/grpc-maven-plugin-annotate-generated-classes/9610/1 "2022-03-16T10:46:09Z")

</div>

Hi,

I’m using the grpc maven plugin to generate java classes from proto files.  
I would like to annotate classes that are generated to exclude these from code analysis (sonar, …).

I would like to use the protoc feature --java\_out=annotate\_code.

> <https://github.com/protocolbuffers/protobuf/issues/42>
>
> \`javax.annotation.Generated\` exists since Java 6 (relevant \[javadoc\](http://docs….oracle.com/javase/6/docs/api/javax/annotation/Generated.html)) so it should be safe to generate source code that contains it. The presence of this annotation has no impact on the runtime characteristics of the annotated classes.
> 
> When this annotation is present it greatly helps in configuration of different tools related to code analysis, tests and tests coverage. 
> 
> Both the outer Java class and all inner builder and message classes and interfaces should be annotated with \`javax.annotation.Generated\`.

I tried following but it has no effect:

```auto
<plugin>
        <groupId>com.lightbend.akka.grpc</groupId>
        <artifactId>akka-grpc-maven-plugin</artifactId>
        <version>${akka.grpc.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <generatorSettings>
                <annotateCode>true</annotateCode>
              </generatorSettings>
            </configuration>
          </execution>
        </executions>
      </plugin>

```

Is there any solution for that?

Best  
Sigurd

---

<div class="post-metadata">

**Author:** ![raboof](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/raboof/32/2913_2.png) [@raboof](https://discuss.akka.io/u/raboof)\
**Post date:** [March 21, 2022, 11:25am UTC](https://discuss.akka.io/t/grpc-maven-plugin-annotate-generated-classes/9610/2 "2022-03-21T11:25:26Z")

</div>

> [@sigurd](#):
>
> I would like to use the protoc feature --java\_out=annotate\_code.

That looks pretty interesting!

Unfortunately `annotate_code` is currently not whitelisted in [https://github.com/akka/akka-grpc/blob/main/codegen/src/main/scala/akka/grpc/gen/ProtocSettings.scala#L10](https://github.com/akka/akka-grpc/blob/main/codegen/src/main/scala/akka/grpc/gen/ProtocSettings.scala#L10). Could you try adding it there and seeing if that has the desired effect?

(I think that would be the easiest way forward, and if it indeed works you can PR the change and that’d benefit all Akka gRPC users. For cases where this is somehow not an option there is an ‘escape hatch’: you can use a ‘plain’ protoc maven plugin instead of the akka-grpc maven plugin - but that’s less convenient and not really documented yet currently…)
