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# This package tests importing extension functions. 16load("//kotlin:rules.bzl", "kt_jvm_library") 17 18licenses(["notice"]) 19 20# During coverage builds, every library gets a dep on JaCoCo (Java Code Coverage). 21# Libjars, from libraries, only include their direct sources. Together, these behaviours 22# trigger an ImportDepsChecker error for :car-jar and :car-inline-jar. To prevent that, we disable 23# coverage builds on all downstream targets. 24_NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO = ["nozapfhahn"] 25 26kt_jvm_library( 27 name = "car_demo_src_lib", 28 srcs = ["CarDemo.kt"], 29 deps = [ 30 "//tests/jvm/java/functions/car:car_lib", 31 ], 32) 33 34# This binary is built from source and shouldn't have any issues loading functions. 35java_test( 36 name = "car_src_demo", 37 main_class = "functions.CarDemo", 38 tags = ["darwin_x86_64_compatible"], 39 runtime_deps = [ 40 ":car_demo_src_lib", 41 ], 42) 43 44kt_jvm_library( 45 name = "car_demo_import_lib", 46 srcs = ["CarDemo.kt"], 47 tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 48 deps = [ 49 "//tests/jvm/java/functions/car:car_lib_import", 50 ], 51) 52 53# This binary includes extension functions defined in an separate jar file, which 54# may be problematic if the metadata is stripped by ijar. 55java_test( 56 name = "car_import_demo", 57 main_class = "functions.CarDemo", 58 tags = ["darwin_x86_64_compatible"] + _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 59 runtime_deps = [ 60 ":car_demo_import_lib", 61 "@kotlinc//:kotlin_stdlib", 62 ], 63) 64 65kt_jvm_library( 66 name = "car_demo_inline_lib", 67 srcs = ["CarInlineDemo.kt"], 68 tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 69 deps = [ 70 "//tests/jvm/java/functions/car:car_inline_and_extra_lib_import", 71 "//tests/jvm/java/functions/car:car_lib_import", 72 ], 73) 74 75# This binary includes inline functions, imported from a jar file using kt_jvm_import. 76# Inlined functions cannot be imported using java_import, since ijar strips out functionality. 77java_test( 78 name = "car_inline_demo", 79 main_class = "functions.CarInlineDemo", 80 tags = ["darwin_x86_64_compatible"] + _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 81 runtime_deps = [ 82 ":car_demo_inline_lib", 83 "@kotlinc//:kotlin_stdlib", 84 ], 85) 86