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

[ggj][bazel] fix: build resnames separately and extract into proto dir #324

Merged
merged 26 commits into from
Sep 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
fd218de
feat: add protobuf comment parser util
miraleung Sep 15, 2020
8c792e3
fix: add basic proto build rules
miraleung Sep 15, 2020
d6ee068
feat: add header comments to ServiceClient
miraleung Sep 15, 2020
82aa0b6
fix: build protoc at test time
miraleung Sep 15, 2020
c8f2233
Merge branch 'gp/g0' of github.com:googleapis/gapic-generator-java in…
miraleung Sep 15, 2020
2405b1a
fix!: wrap protobuf location and process comments
miraleung Sep 15, 2020
a59fd3f
feat: add comment parsing to methods and fields
miraleung Sep 16, 2020
66dec11
fix: test
miraleung Sep 16, 2020
8325450
feat: add protobuf comments to ServiceClient
miraleung Sep 16, 2020
5acc151
fix: solidify codegen method order with TypeNode/MethodArg and Compar…
miraleung Sep 16, 2020
97e780a
fix: clean up tests
miraleung Sep 16, 2020
5508e67
fix: merge gp/g2_5
miraleung Sep 17, 2020
0b7288e
fix: merge
miraleung Sep 17, 2020
c6ca60b
fix: ServiceClient member variables and method calls
miraleung Sep 18, 2020
ac89e12
fix: ServiceStubSettings builder type
miraleung Sep 18, 2020
b5e6585
fix: ServiceSettings Builder construction
miraleung Sep 18, 2020
1e10b6b
fix: ServiceStub callable types
miraleung Sep 18, 2020
006aff4
feat: java_gapic_library rule impl
miraleung Sep 18, 2020
f25274f
fix: remove debugging comments
miraleung Sep 18, 2020
76d26d8
feat: add gradle assembly Bazel rules
miraleung Sep 18, 2020
c56271f
feat: add java_gapic_test Bazel rule
miraleung Sep 18, 2020
98ccc00
fix: use Java packages for resname codegen
miraleung Sep 18, 2020
5eed26a
fix: build resnames separately and extract into proto/ dir
miraleung Sep 18, 2020
3b238ff
fix: remove debug printf
miraleung Sep 18, 2020
4563c4a
fix: empty change to force re-run
miraleung Sep 19, 2020
32a117d
Merge branch 'master' into gp/g13
miraleung Sep 19, 2020
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
26 changes: 22 additions & 4 deletions rules_java_gapic/java_gapic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def _java_gapic_postprocess_srcjar_impl(ctx):
output_srcjar_name = ctx.label.name
output_main = ctx.outputs.main
output_test = ctx.outputs.test
output_resource_name = ctx.outputs.resource_name
formatter = ctx.executable.formatter

output_dir_name = ctx.label.name
Expand All @@ -30,25 +31,28 @@ def _java_gapic_postprocess_srcjar_impl(ctx):
unzip -q temp-codegen.srcjar -d {output_dir_path}
# This may fail if there are spaces and/or too many files (exceed max length of command length).
{formatter} --replace $(find {output_dir_path} -type f -printf "%p ")
zip -r -j {output_srcjar_name}.srcjar {output_dir_path}/src/main/* {output_dir_path}/proto/src/main/*
zip -r -j {output_srcjar_name}.srcjar {output_dir_path}/src/main/*
zip -r -j {output_srcjar_name}-resource-name.srcjar {output_dir_path}/proto/src/main/*
zip -r -j {output_srcjar_name}-tests.srcjar {output_dir_path}/src/test/*
mv {output_srcjar_name}.srcjar {output_main}
mv {output_srcjar_name}-resource-name.srcjar {output_resource_name}
mv {output_srcjar_name}-tests.srcjar {output_test}
""".format(
gapic_srcjar = gapic_srcjar.path,
output_srcjar_name = output_srcjar_name,
output_main = output_main.path,
formatter = formatter,
output_dir_name = output_dir_name,
output_dir_path = output_dir_path,
output_main = output_main.path,
output_resource_name = output_resource_name.path,
output_test = output_test.path,
)

ctx.actions.run_shell(
inputs = [gapic_srcjar],
tools = [formatter],
command = script,
outputs = [output_main, output_test],
outputs = [output_main, output_resource_name, output_test],
)

_java_gapic_postprocess_srcjar = rule(
Expand All @@ -62,6 +66,7 @@ _java_gapic_postprocess_srcjar = rule(
},
outputs = {
"main": "%{name}.srcjar",
"resource_name": "%{name}-resource-name.srcjar",
"test": "%{name}-test.srcjar",
},
implementation = _java_gapic_postprocess_srcjar_impl,
Expand Down Expand Up @@ -111,8 +116,21 @@ def java_gapic_library(
**kwargs
)

resource_name_name = "%s_resource_name" % name
resource_name_deps = [resource_name_name]
native.java_library(
name = resource_name_name,
srcs = ["%s-resource-name.srcjar" % srcjar_name],
deps = [
"@com_google_api_api_common//jar",
"@com_google_guava_guava//jar",
"@javax_annotation_javax_annotation_api//jar",
],
**kwargs
)

# General additional deps.
actual_deps = deps + [
actual_deps = deps + resource_name_deps + [
"@com_google_googleapis//google/rpc:rpc_java_proto",
"@com_google_googleapis//google/longrunning:longrunning_java_proto",
"@com_google_protobuf//:protobuf_java",
Expand Down
1 change: 1 addition & 0 deletions rules_java_gapic/java_gapic_pkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def java_gapic_assembly_gradle_pkg(
if "_java_gapic" in dep:
_put_dep_in_a_bucket(dep, client_deps, processed_deps)
_put_dep_in_a_bucket("%s_test" % dep, client_test_deps, processed_deps)
_put_dep_in_a_bucket("%s_resource_name" % dep, proto_deps, processed_deps)
elif dep.endswith("_java_grpc"):
_put_dep_in_a_bucket(dep, grpc_deps, processed_deps)
else:
Expand Down