Skip to content

Commit bb128d4

Browse files
committed
feat: re-enable Java example of using pre-built protoc
1 parent 78d8f78 commit bb128d4

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

examples/MODULE.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_j
7373

7474
http_jar(
7575
name = "protobuf-java",
76-
sha256 = "0532ad1024d62361561acaedb974d7d16889e7670b36e23e9321dd6b9d334ef9",
77-
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.27.0-RC3/protobuf-java-4.27.0-RC3.jar"],
76+
integrity = "sha256-rSOIR3s7lplCQeZHMaE2iU3J/tbeufJ21ISosXGxRQw=",
77+
urls = ["https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.28.0/protobuf-java-4.28.0.jar"],
7878
)
7979

8080
####### RUST ##########

examples/java/BUILD

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# See comment in examples/BUILD.bazel
2-
# java_binary(
3-
# name = "java",
4-
# srcs = ["Main.java"],
5-
# main_class = "Main",
6-
# deps = [
7-
# "//:foo_java_proto",
8-
# "@protobuf-java//jar",
9-
# ],
10-
# )
1+
java_binary(
2+
name = "java",
3+
srcs = ["Main.java"],
4+
main_class = "Main",
5+
deps = [
6+
"//proto:greeter_java_proto",
7+
"@protobuf-java//jar",
8+
],
9+
)

examples/java/Main.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import com.google.protobuf.InvalidProtocolBufferException;
2-
import static proto.FooOuterClass.Foo;
2+
import static proto.GreeterOuterClass.HelloReply;
33

44
public class Main {
55
public static void main(String[] args) throws InvalidProtocolBufferException {
66
System.out.println(makeMessage("Hello World!"));
77
}
88

9-
public static Foo makeMessage(String msg) {
10-
Foo.Builder person = Foo.newBuilder();
11-
person.setMsg(msg);
12-
return person.build();
9+
public static HelloReply makeMessage(String msg) {
10+
HelloReply.Builder response = HelloReply.newBuilder();
11+
response.setMessage(msg);
12+
return response.build();
1313
}
1414
}

examples/proto/BUILD.bazel

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ py_proto_library(
1717
deps = [":greeter_proto"],
1818
)
1919

20+
java_proto_library(
21+
name = "greeter_java_proto",
22+
deps = [":greeter_proto"],
23+
)
24+
2025
# Broken by https://github.com/protocolbuffers/protobuf/pull/19679
2126
# which causes building C++ code from source.
2227
# TODO: re-enable once protobuf honors the toolchain

0 commit comments

Comments
 (0)