Skip to content

Commit e7855ce

Browse files
alexeaglethesayyn
authored andcommitted
feat: re-enable Java example of using pre-built protoc
1 parent cb688bf commit e7855ce

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

examples/java/BUILD

Lines changed: 9 additions & 10 deletions
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

Lines changed: 5 additions & 5 deletions
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.HelloRequest;
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 HelloRequest makeMessage(String msg) {
10+
HelloRequest.Builder req = HelloRequest.newBuilder();
11+
req.setName(msg);
12+
return req.build();
1313
}
1414
}

examples/proto/BUILD.bazel

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
load("@aspect_rules_ts//ts:proto.bzl", "ts_proto_library")
2+
load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library")
3+
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
24
load("@rules_go//proto:def.bzl", "go_proto_library")
35
load("@rules_proto//proto:defs.bzl", "proto_library")
46
load("@rules_rust_prost//:defs.bzl", "rust_prost_library")
5-
load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library")
67

78
package(default_visibility = ["//visibility:public"])
89

@@ -19,11 +20,10 @@ py_proto_library(
1920

2021
# Broken by https://github.com/protocolbuffers/protobuf/pull/19679
2122
# 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-
# )
23+
java_proto_library(
24+
name = "greeter_java_proto",
25+
deps = [":greeter_proto"],
26+
)
2727

2828
go_proto_library(
2929
name = "greeter_go_proto",

0 commit comments

Comments
 (0)