Skip to content

Commit 4c75fc1

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

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
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

+4-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ py_proto_library(
1717
deps = [":greeter_proto"],
1818
)
1919

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

2825
go_proto_library(
2926
name = "greeter_go_proto",

0 commit comments

Comments
 (0)