Skip to content

Commit 2bf0a5b

Browse files
authored
Merge pull request #57 from qu8n/update-readme-on-proto
Update README on working with Java code generated from .proto
2 parents 557d8cd + 3353bce commit 2bf0a5b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SMILE Commons
22

3-
Centralized configurations for checkstyle plugin and dependency management.
3+
Centralized configurations for checkstyle plugin and dependency management.
44

55
## OpenTelemetryUtils
66

@@ -17,7 +17,7 @@ import org.mskcc.smile.commons.OpenTelemetryUtils.TraceMetadata;
1717
@Autowired
1818
OpenTelemetryUtils openTelemetryUtils;
1919

20-
// OpenTelemetry Tracer
20+
// OpenTelemetry Tracer
2121
private static final Tracer tracer = GlobalOpenTelemetry.get().getTracer("org.mskcc.cmo.Classname");
2222

2323
// Upstream service propagating context to downstream service via a Nats Message
@@ -50,3 +50,22 @@ public void onMessage(Message msg, Object message)
5050
}
5151
}
5252
```
53+
## Updating Java Code Generated from Protobuf Files
54+
55+
Java classes inside `./src/main/java/org/mskcc/smile/commons/generated/` are manually generated.
56+
57+
To update existing or create new classes, follow these steps:
58+
- Obtain or construct the `.proto` file
59+
- Ensure that the correct `protoc` version is installed (see more in notes below)
60+
- Run `$ protoc [path to .proto file] --java_out=[directory to write the Java generated code to]`
61+
- Ensure the newly generated Java classes are saved at `./src/main/java/org/mskcc/smile/commons/generated/`
62+
- Update `pom.xml` if there are changes to the Protobuf Java version
63+
64+
### Version of `protoc` to Use
65+
Per the [Protobuf docs](https://protobuf.dev/support/version-support/#java):
66+
> The protoc version can be inferred from the Protobuf Java minor version number. Example: Protobuf Java version 3.**25**.x uses protoc version **25**.x.".
67+
68+
Based on this, follow these steps to determine the correct `protoc` version to use:
69+
- Note the Java version of the Java application needing the Protobuf Java classes (e.g. Java 21)
70+
- Find the Protobuf Java version that is compatible with the Java application (e.g. Protobuf Java 4.26.1 supports Java 21)
71+
- Determine the protoc version needed from the Protobuf Java minor version number (e.g. Protobuf Java 4.26.1 uses protoc 26.x)

0 commit comments

Comments
 (0)