Skip to content

Commit

Permalink
Decouple java_lite_proto_library from java_proto_library
Browse files Browse the repository at this point in the history
Remove call to java_proto_library_impl from java_proto_library.

Remove hasattr from java_proto_library_impl, which handled java_lite_proto_library.

Code reuse in this case made little sense, and it incurrent more maintenance cost than benefit.

Issue: bazelbuild/rules_proto#179
PiperOrigin-RevId: 570053518
Change-Id: Ie43cadfd1fc324b6aaad08acaca8eea7df1a3669
  • Loading branch information
comius committed Jan 17, 2024
1 parent 0895719 commit 8ea74cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""A Starlark implementation of the java_lite_proto_library rule."""

load(":common/java/java_semantics.bzl", "semantics")
load(":common/java/proto/java_proto_library.bzl", "JavaProtoAspectInfo", "java_compile_for_protos")
load(":common/proto/proto_common.bzl", "ProtoLangToolchainInfo", proto_common = "proto_common_do_not_use")
load(":common/java/proto/java_proto_library.bzl", "JavaProtoAspectInfo", "bazel_java_proto_library_rule", "java_compile_for_protos")

PROTO_TOOLCHAIN_ATTR = "_aspect_proto_toolchain_for_javalite"

Expand Down Expand Up @@ -106,13 +106,20 @@ def _rule_impl(ctx):
else:
proguard_provider_specs = ProguardSpecProvider(depset())

java_info, DefaultInfo, OutputGroupInfo = bazel_java_proto_library_rule(ctx)
java_info = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs = False)

transitive_src_and_runtime_jars = depset(transitive = [dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps])
transitive_runtime_jars = depset(transitive = [java_info.transitive_runtime_jars])

java_info = semantics.add_constraints(java_info, ["android"])

return [
java_info,
DefaultInfo,
OutputGroupInfo,
DefaultInfo(
files = transitive_src_and_runtime_jars,
runfiles = ctx.runfiles(transitive_files = transitive_runtime_jars),
),
OutputGroupInfo(default = depset()),
proguard_provider_specs,
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def bazel_java_proto_library_rule(ctx):
Returns:
([JavaInfo, DefaultInfo, OutputGroupInfo])
"""

java_info = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs = False)

transitive_src_and_runtime_jars = depset(transitive = [dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps])
Expand Down

0 comments on commit 8ea74cd

Please sign in to comment.