1# Copyright 2018 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Rule adapter for _java_lite_grpc_library.""" 15 16load(":adapters/base.bzl", "make_adapter") 17load(":providers.bzl", "MIAndroidDexInfo", "MIJavaResourcesInfo", "providers") 18load(":transform.bzl", "dex", "extract_jar_resources") 19 20def _aspect_attrs(): 21 """Attrs of the rule requiring traversal by the aspect.""" 22 return ["deps", "_toolchain"] 23 24def _adapt(target, ctx): 25 """Adapts the rule and target data. 26 27 Args: 28 target: The target. 29 ctx: The context. 30 31 Returns: 32 A list of providers. 33 """ 34 return [ 35 providers.make_mi_android_dex_info( 36 dex_shards = dex( 37 ctx, 38 target[JavaInfo].runtime_output_jars, 39 target[JavaInfo].transitive_compile_time_jars, 40 ), 41 deps = providers.collect( 42 MIAndroidDexInfo, 43 ctx.rule.attr.deps, 44 [ctx.rule.attr._toolchain], 45 ), 46 ), 47 providers.make_mi_java_resources_info( 48 java_resources = extract_jar_resources( 49 ctx, 50 target[JavaInfo].runtime_output_jars, 51 ), 52 deps = providers.collect( 53 MIJavaResourcesInfo, 54 ctx.rule.attr.deps, 55 ), 56 ), 57 ] 58 59java_lite_grpc_library = make_adapter(_aspect_attrs, _adapt) 60