xref: /aosp_15_r20/external/bazelbuild-kotlin-rules/tests/jvm/analysis/jvm_library/friends/BUILD (revision 3a22c0a33dd99bcca39a024d43e6fbcc55c2806e)
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
15load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
16load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test")
17
18package(
19    default_applicable_licenses = ["//:license"],
20    default_testonly = True,
21    default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"],
22)
23
24licenses(["notice"])
25
26kt_jvm_library_analysis_test(
27    name = "no_kt_exported_friend_cross_package_test",
28    expected_friend_jar_names = [],
29    target_under_test = ktfa.kt_jvm_library(
30        name = "no_kt_exported_friend_cross_package",
31        srcs = ["Input.kt"],
32        deps = [
33            # Exports :friend from this package
34            "//tests/jvm/analysis/jvm_library/friends/sub:kt_exports_friend",
35        ],
36    ),
37)
38
39kt_jvm_library_analysis_test(
40    name = "has_java_exported_friend_in_package_test",
41    expected_friend_jar_names = [
42        "libjava_exports_friend-hjar.jar",
43        "libfriend-compile.jar",
44    ],
45    target_under_test = ktfa.kt_jvm_library(
46        name = "has_java_exported_friend_in_package",
47        srcs = ["Input.kt"],
48        deps = [":java_exports_friend"],
49    ),
50)
51
52kt_jvm_library_analysis_test(
53    name = "has_kt_exported_friend_in_package_test",
54    expected_friend_jar_names = [
55        "libkt_exports_friend-compile.jar",
56        "libfriend-compile.jar",
57    ],
58    target_under_test = ktfa.kt_jvm_library(
59        name = "has_kt_exported_friend_in_package",
60        srcs = ["Input.kt"],
61        deps = [":kt_exports_friend"],
62    ),
63)
64
65kt_jvm_library_analysis_test(
66    name = "no_direct_friend_testing_package_test",
67    expected_friend_jar_names = [],
68    target_under_test = ktfa.kt_jvm_library(
69        name = "no_direct_friend_testing_package",
70        srcs = ["Input.kt"],
71        deps = ["//tests/jvm/analysis/jvm_library/friends/testing:testingfriend"],
72    ),
73)
74
75kt_jvm_library_analysis_test(
76    name = "no_direct_friend_subpackage_test",
77    expected_friend_jar_names = [],
78    target_under_test = ktfa.kt_jvm_library(
79        name = "no_direct_friend_subpackage",
80        srcs = ["Input.kt"],
81        deps = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"],
82    ),
83)
84
85kt_jvm_library_analysis_test(
86    name = "has_direct_friend_in_package_test",
87    expected_friend_jar_names = ["libfriend-compile.jar"],
88    target_under_test = ktfa.kt_jvm_library(
89        name = "has_direct_friend_in_package",
90        srcs = ["Input.kt"],
91        deps = [":friend"],
92    ),
93)
94
95ktfa.java_library(
96    name = "java_exports_friend",
97    srcs = ["Input.java"],
98    exports = [":friend"],
99)
100
101ktfa.kt_jvm_library(
102    name = "kt_exports_friend",
103    srcs = ["Input.kt"],
104    exports = [":friend"],
105)
106
107ktfa.kt_jvm_library(
108    name = "friend",
109    srcs = ["Input.kt"],
110)
111