1# Copyright 2022 Google LLC. 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 15"""kt_friend_jars_visitor""" 16 17load("//:visibility.bzl", "RULES_KOTLIN") 18load("//kotlin/common:is_eligible_friend.bzl", "is_eligible_friend") 19 20visibility(RULES_KOTLIN) 21 22def _get_output_jars(target, _ctx_rule): 23 # We can't simply use `JavaInfo.compile_jars` because we only want the JARs directly created by 24 # `target`, and not JARs from its `exports` 25 return [output.compile_jar for output in target[JavaInfo].java_outputs if output.compile_jar] 26 27kt_friend_jars_visitor = struct( 28 name = "friend_jars", 29 visit_target = _get_output_jars, 30 filter_edge = is_eligible_friend, 31 finish_expansion = None, 32 process_unvisited_target = None, 33) 34