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:rules.bzl", "kt_jvm_import", "kt_jvm_library") 16 17package( 18 default_testonly = 1, 19) 20 21licenses(["notice"]) 22 23# During coverage builds, every library gets a dep on JaCoCo (Java Code Coverage). 24# Libjars, from libraries, only include their direct sources. Together, these behaviours 25# trigger an ImportDepsChecker error for :import_a_and_b. To prevent that, we disable 26# coverage builds on all downstream targets. 27_NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO = ["nozapfhahn"] 28 29kt_jvm_library( 30 name = "A", 31 srcs = ["A.kt"], 32) 33 34kt_jvm_library( 35 name = "B", 36 srcs = ["B.kt"], 37 deps = [":A"], 38) 39 40# This import target with multiple JARs is the main thing we're testing. 41kt_jvm_import( 42 name = "import_a_and_b", 43 jars = [ 44 ":libA.jar", 45 ":libB.jar", 46 ], 47 srcjar = ":libB-src.jar", 48 tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 49) 50 51kt_jvm_library( 52 name = "TestRunner", 53 srcs = ["TestRunner.kt"], 54 tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 55 deps = [":import_a_and_b"], 56) 57 58java_test( 59 name = "multijarimport_test", 60 main_class = "multijarimport.TestRunner", 61 tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 62 runtime_deps = [ 63 ":TestRunner", 64 ], 65) 66