Grpc maven plugin: annotate generated classes

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.

I tried following but it has no effect:

<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

That looks pretty interesting!

Unfortunately annotate_code is currently not whitelisted in akka-grpc/ProtocSettings.scala at main · akka/akka-grpc · GitHub. 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…)