From 8ea74cda233ca7aa7acdfbc2f619b42ca5e991bc Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 2 Oct 2023 06:56:47 -0700 Subject: [PATCH] Decouple java_lite_proto_library from java_proto_library 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: https://github.com/bazelbuild/rules_proto/issues/179 PiperOrigin-RevId: 570053518 Change-Id: Ie43cadfd1fc324b6aaad08acaca8eea7df1a3669 --- .../common/java/proto/java_lite_proto_library.bzl | 15 +++++++++++---- .../common/java/proto/java_proto_library.bzl | 1 - 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/starlark/builtins_bzl/common/java/proto/java_lite_proto_library.bzl b/src/main/starlark/builtins_bzl/common/java/proto/java_lite_proto_library.bzl index 56afa3f41c0dca..fbe4f387dda8c9 100644 --- a/src/main/starlark/builtins_bzl/common/java/proto/java_lite_proto_library.bzl +++ b/src/main/starlark/builtins_bzl/common/java/proto/java_lite_proto_library.bzl @@ -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" @@ -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, ] diff --git a/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl b/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl index 09690f027282ce..334eeba5d948d6 100644 --- a/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl +++ b/src/main/starlark/builtins_bzl/common/java/proto/java_proto_library.bzl @@ -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])