Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: re-enable Java example of using pre-built protoc #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_j

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

####### RUST ##########
Expand Down
19 changes: 9 additions & 10 deletions examples/java/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# See comment in examples/BUILD.bazel
# java_binary(
# name = "java",
# srcs = ["Main.java"],
# main_class = "Main",
# deps = [
# "//:foo_java_proto",
# "@protobuf-java//jar",
# ],
# )
java_binary(
name = "java",
srcs = ["Main.java"],
main_class = "Main",
deps = [
"//proto:greeter_java_proto",
"@protobuf-java//jar",
],
)
10 changes: 5 additions & 5 deletions examples/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import com.google.protobuf.InvalidProtocolBufferException;
import static proto.FooOuterClass.Foo;
import static proto.GreeterOuterClass.HelloReply;

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

public static Foo makeMessage(String msg) {
Foo.Builder person = Foo.newBuilder();
person.setMsg(msg);
return person.build();
public static HelloReply makeMessage(String msg) {
HelloReply.Builder response = HelloReply.newBuilder();
response.setMessage(msg);
return response.build();
}
}
11 changes: 4 additions & 7 deletions examples/proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ py_proto_library(
deps = [":greeter_proto"],
)

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

go_proto_library(
name = "greeter_go_proto",
Expand Down
Loading