From 09100d2c960a026dfd19825b858c4c63747999d9 Mon Sep 17 00:00:00 2001 From: Chris Bono Date: Mon, 26 May 2025 13:33:29 -0500 Subject: [PATCH] Polish "Improve Gradle instructions in README.md" - Makes all Maven and Gradle commands use the wrappers - Corrects the generated paths for Maven - Moves note about package name up to admonition Signed-off-by: Chris Bono --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2b0b363..087906e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ For further information go to our [Spring gRPC reference documentation](https:// # Getting Started -This section offers jumping off points for how to get started using Spring gRPC. There is a simple sample project in the `samples` directory (e.g. [`grpc-server`](https://github.com/spring-projects/spring-grpc/tree/main/samples/grpc-server)). You can run it with `mvn spring-boot:run` or `gradle bootRun`. You will see the following code in that sample. +This section offers jumping off points for how to get started using Spring gRPC. There is a simple sample project in the `samples` directory (e.g. [`grpc-server`](https://github.com/spring-projects/spring-grpc/tree/main/samples/grpc-server)). You can run it with `./mvnw spring-boot:run` or `./gradlew bootRun`. You will see the following code in that sample. Want to get started? Let’s speedrun a working service. @@ -21,11 +21,13 @@ Open it in your IDE in the usual way. E.g. if you’re using IntelliJ IDEA: `ide Define a `.proto` service definition file `src/main/proto/hello.proto` with the following contents: +IMPORTANT: Be sure to change the `java_package` to the one you chose in Spring Initializr + ```proto syntax = "proto3"; option java_multiple_files = true; -option java_package = "org.springframework.grpc.sample.proto"; // !IMP: change the package name to the one you mentioned in spring initilizr +option java_package = ".proto"; option java_outer_classname = "HelloWorldProto"; // The greeting service definition. @@ -58,9 +60,15 @@ or ./gradlew build ``` -You’ll get two new folders in the `target` directory: `target/target/generated-sources/protobuf/grpc-java` and `target/target/generated-sources/protobuf/java`. -(_For gradle_, refer the `build` directory: `build/generated/source/proto/main/grpc` & `build/generated/source/proto/main/java`) -You may need to instruct your IDE to mark them as source roots. In IntelliJ IDEA, you’d right-click the folder, choose `Mark Directory As` -> `Generated Source Root`. Eclipse or VSCode will add them automatically for you. +Two new folders will be generated containing the source code for the stubs. + +_For Maven_: `target/generated-sources/protobuf/grpc-java` and `target/generated-sources/protobuf/java`. + +_For Gradle_: `build/generated/source/proto/main/grpc` and `build/generated/source/proto/main/java`) + +You may need to instruct your IDE to mark them as source roots. +In IntelliJ IDEA, right-click the folder, choose `Mark Directory As` -> `Generated Source Root`. +Eclipse or VSCode will add them automatically for you. Now you can implement a service based on the generated stubs: @@ -246,7 +254,7 @@ public class GrpcServerApplication { } ``` -Run it from your IDE, or on the command line with `mvn spring-boot:run` or `gradle bootRun`. +Run it from your IDE, or on the command line with `./mvnw spring-boot:run` or `./gradlew bootRun`. ### gRPC Client