Skip to content

Commit 4813464

Browse files
committed
address PR feedback
1 parent 1c4453c commit 4813464

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

BUILD.bazel

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ load(
88
package(default_visibility = ["//visibility:public"])
99

1010
JAVA_SRCS = [
11+
"//src/main/java/com/google/api/generator/debug:debug_files",
1112
"//src/main/java/com/google/api/generator:generator_files",
1213
"//src/main/java/com/google/api/generator/engine:engine_files",
1314
"//src/main/java/com/google/api/generator/gapic:gapic_files",
@@ -53,6 +54,16 @@ java_binary(
5354
# directly (instead of relying on protoc to start the process), which would give
5455
# much greater flexibility in terms of debugging features, like attaching a
5556
# debugger, easier work with stdout and stderr etc.
57+
#
58+
# Usage example, via the rule in a corresponding BUILD.bazel file:
59+
#
60+
# load("@gapic_generator_java//rules_java_gapic:java_gapic.bzl", "java_generator_request_dump")
61+
# java_generator_request_dump(
62+
# name = "compute_small_request_dump",
63+
# srcs = [":compute_small_proto_with_info"],
64+
# transport = "rest",
65+
# )
66+
#
5667
java_binary(
5768
name = "protoc-gen-code_generator_request_dumper",
5869
main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper",
@@ -69,9 +80,14 @@ java_binary(
6980

7081
# A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest
7182
# directly from a file instead of relying on protoc to pipe it in.
83+
#
84+
# Usage example:
85+
#
86+
# bazel run code_generator_request_file_to_gapic_main desc-dump.bin dump.jar
87+
#
7288
java_binary(
73-
name = "protoc-gen-java_gapic_from_file",
74-
main_class = "com.google.api.generator.debug.MainStandalone",
89+
name = "code_generator_request_file_to_gapic_main",
90+
main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain",
7591
runtime_deps = [
7692
"//src/main/java/com/google/api/generator",
7793
"//src/main/java/com/google/api/generator/debug",

src/main/java/com/google/api/generator/debug/CodeGeneratorRequestDumper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
import com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse;
2121
import java.io.IOException;
2222

23+
// Request dumper class, which dumps the CodeGeneratorRequest to a file on disk which will be
24+
// identical to the one passed to the Main class during normal execution. The dumped file then can
25+
// be used to run this gapic-generator directly (instead of relying on protoc to start the process),
26+
// which would give much greater flexibility in terms of debugging features, like attaching a
27+
// debugger, easier work with stdout and stderr etc.
2328
public class CodeGeneratorRequestDumper {
2429
public static void main(String[] args) throws IOException {
2530
ExtensionRegistry registry = ExtensionRegistry.newInstance();

src/main/java/com/google/api/generator/debug/MainStandalone.java renamed to src/main/java/com/google/api/generator/debug/CodeGeneratorRequestFileToGapicMain.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
import java.io.InputStream;
2626
import java.io.OutputStream;
2727

28-
public class MainStandalone {
28+
// A generator entry point class, similar to Main but reads the CodeGeneratorRequest directly from a
29+
// file instead of relying on protoc to pipe it in.
30+
public class CodeGeneratorRequestFileToGapicMain {
2931
public static void main(String[] args) throws IOException {
3032
ExtensionRegistry registry = ExtensionRegistry.newInstance();
3133
ProtoRegistry.registerAllExtensions(registry);

0 commit comments

Comments
 (0)