=== Protobuf generated code

Camel Quarkus gRPC can generate gRPC service stubs for `.proto` files. When using Maven, ensure that you have
enabled the `generate-code` goals of the `quarkus-maven-plugin` in your project build.

[source,xml]
----
<build>
    <plugins>
        <plugin>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-maven-plugin</artifactId>
            <version>${quarkus.platform.version}</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <goals>
                        <goal>build</goal>
                        <goal>generate-code</goal>
                        <goal>generate-code-tests</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
----

With this configuration, you can put your service and message definitions into the `src/main/proto` directory and
the `quarkus-maven-plugin` will generate code from your `.proto` files.

==== Scanning `proto` files with imports

The Protocol Buffers specification provides a way to import proto files. You can control the scope of dependencies to
scan by adding configuration property `quarkus.camel.grpc.codegen.scan-for-imports` property to `application.properties`.
The available options are outlined below.

* `all` - Scan all dependencies
* `none` - Disable dependency scanning. Use only the proto definitions defined in `src/main/proto` or `src/test/proto`
* `groupId1:artifactId1,groupId2:artifactId2` - Scan only the dependencies matching the `groupId` and `artifactId` list

The default value is `com.google.protobuf:protobuf-java`.

==== Scanning `proto` files from dependencies

If you have proto files shared across multiple dependencies, you can generate gRPC service stubs for them by adding
configuration property `quarkus.camel.grpc.codegen.scan-for-proto` to `application.properties`.

First add a dependency for the artifact(s) containing proto files to your project. Next, enable proto file
dependency scanning.

[source,properties]
----
quarkus.camel.grpc.codegen.scan-for-proto=org.my.groupId1:my-artifact-id-1,org.my.groupId2:my-artifact-id-2
----

It is possible to include / exclude specific proto files from dependency scanning via configuration properties.

The configuration property name suffix is the Maven `groupId` / `artifactId` for the dependency to configure includes / excludes on.
Paths are relative to the classpath location of the proto files within the dependency. Paths can be an explicit path to a proto file,
or as glob patterns to include / exclude multiple files.

[source,properties]
----
quarkus.camel.grpc.codegen.scan-for-proto-includes."<groupId>\:<artifactId>"=foo/**,bar/**,baz/a-proto.proto
quarkus.camel.grpc.codegen.scan-for-proto-excludes."<groupId>\:<artifactId>"=foo/private/**,baz/another-proto.proto
----

NOTE: The `:` character within property keys must be escaped with `\`.

=== Accessing classpath resources in native mode

The gRPC component has various options where resources are resolved from the classpath:

* `keyCertChainResource`
* `keyResource`
* `serviceAccountResource`
* `trustCertCollectionResource`

When using these options in native mode, you must ensure that any such resources are included in the native image.

This can be accomplished by adding the configuration property `quarkus.native.resources.includes` to `application.properties`.
For example, to include SSL / TLS keys and certificates.

[source,properties]
----
quarkus.native.resources.includes = certs/*.pem,certs.*.key
----

More information about selecting resources for inclusion in the native executable can be found in the xref:user-guide/native-mode.adoc#embedding-resource-in-native-executable[native mode guide].
