Code generation produces source code and project resources automatically from application settings, extensions, templates, or schema definitions. In Quarkus, creating an application with sample generation can produce REST endpoints, configuration, Dockerfiles, and tests alongside the project structure. section 2.2.2
Generated artifacts commonly support several development tasks:
- Create a sample JAX-RS resource such as a GET /hello endpoint from the selected REST extension. section 2.2.2
- Provide configuration, Dockerfiles for packaging types, and Quarkus test sources in the application layout. section 2.2.2
- Compile a Protocol Buffers schema into Java message classes, builders, and serialization methods. section 4.6.2
- Generate gRPC client and server stubs from service definitions, allowing implementations and callers to use typed Java classes. section 4.7
Generating gRPC code from a service contract
Place inventory.proto under src/main/proto and define messages plus InventoryService methods. Add the quarkus-grpc extension, then run ./mvnw clean package. The extension detects the schema and generates Java sources under target/generated-sources/grpc, including message classes, builders, service bases, and clients. section 4.7
Listing 2.4 GreetingResource class: generated sample JAX-RS endpoint
package org.acme;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
@Path("/hello") #1
public class GreetingResource {
@GET #2
@Produces(MediaType.TEXT_PLAIN) #3
public String hello() {
return "Hello from Quarkus REST"; #4
}
}
Inspect the generated GreetingResource to see how annotations define the /hello path, HTTP method, response type, and returned content. section 2.2.2
Listing 4.36 The files generated from the proto file definition
target/generated-sources/grpc
└── org
└── acme
└── inventory
└── model
├── CarResponse.java
├── CarResponseOrBuilder.java
├── InsertCarRequest.java
├── InsertCarRequestOrBuilder.java
├── InventoryProtos.java
├── InventoryServiceBean.java
├── InventoryServiceClient.java
├── InventoryServiceGrpc.java
├── InventoryService.java
├── MutinyInventoryServiceGrpc.java
├── RemoveCarRequest.java
└── RemoveCarRequestOrBuilder.java
Inspect the generated gRPC source tree to distinguish message classes, builders, service implementations, and client stubs. section 4.7
















