1*3a22c0a3SAlix# Copyright 2022 Google LLC. All rights reserved. 2*3a22c0a3SAlix# 3*3a22c0a3SAlix# Licensed under the Apache License, Version 2.0 (the License); 4*3a22c0a3SAlix# you may not use this file except in compliance with the License. 5*3a22c0a3SAlix# You may obtain a copy of the License at 6*3a22c0a3SAlix# 7*3a22c0a3SAlix# http://www.apache.org/licenses/LICENSE-2.0 8*3a22c0a3SAlix# 9*3a22c0a3SAlix# Unless required by applicable law or agreed to in writing, software 10*3a22c0a3SAlix# distributed under the License is distributed on an "AS IS" BASIS, 11*3a22c0a3SAlix# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*3a22c0a3SAlix# See the License for the specific language governing permissions and 13*3a22c0a3SAlix# limitations under the License. 14*3a22c0a3SAlix 15*3a22c0a3SAlix# This package tests importing extension functions. 16*3a22c0a3SAlixload("//kotlin:rules.bzl", "kt_jvm_library") 17*3a22c0a3SAlix 18*3a22c0a3SAlixlicenses(["notice"]) 19*3a22c0a3SAlix 20*3a22c0a3SAlix# During coverage builds, every library gets a dep on JaCoCo (Java Code Coverage). 21*3a22c0a3SAlix# Libjars, from libraries, only include their direct sources. Together, these behaviours 22*3a22c0a3SAlix# trigger an ImportDepsChecker error for :car-jar and :car-inline-jar. To prevent that, we disable 23*3a22c0a3SAlix# coverage builds on all downstream targets. 24*3a22c0a3SAlix_NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO = ["nozapfhahn"] 25*3a22c0a3SAlix 26*3a22c0a3SAlixkt_jvm_library( 27*3a22c0a3SAlix name = "car_demo_src_lib", 28*3a22c0a3SAlix srcs = ["CarDemo.kt"], 29*3a22c0a3SAlix deps = [ 30*3a22c0a3SAlix "//tests/jvm/java/functions/car:car_lib", 31*3a22c0a3SAlix ], 32*3a22c0a3SAlix) 33*3a22c0a3SAlix 34*3a22c0a3SAlix# This binary is built from source and shouldn't have any issues loading functions. 35*3a22c0a3SAlixjava_test( 36*3a22c0a3SAlix name = "car_src_demo", 37*3a22c0a3SAlix main_class = "functions.CarDemo", 38*3a22c0a3SAlix tags = ["darwin_x86_64_compatible"], 39*3a22c0a3SAlix runtime_deps = [ 40*3a22c0a3SAlix ":car_demo_src_lib", 41*3a22c0a3SAlix ], 42*3a22c0a3SAlix) 43*3a22c0a3SAlix 44*3a22c0a3SAlixkt_jvm_library( 45*3a22c0a3SAlix name = "car_demo_import_lib", 46*3a22c0a3SAlix srcs = ["CarDemo.kt"], 47*3a22c0a3SAlix tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 48*3a22c0a3SAlix deps = [ 49*3a22c0a3SAlix "//tests/jvm/java/functions/car:car_lib_import", 50*3a22c0a3SAlix ], 51*3a22c0a3SAlix) 52*3a22c0a3SAlix 53*3a22c0a3SAlix# This binary includes extension functions defined in an separate jar file, which 54*3a22c0a3SAlix# may be problematic if the metadata is stripped by ijar. 55*3a22c0a3SAlixjava_test( 56*3a22c0a3SAlix name = "car_import_demo", 57*3a22c0a3SAlix main_class = "functions.CarDemo", 58*3a22c0a3SAlix tags = ["darwin_x86_64_compatible"] + _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 59*3a22c0a3SAlix runtime_deps = [ 60*3a22c0a3SAlix ":car_demo_import_lib", 61*3a22c0a3SAlix "@kotlinc//:kotlin_stdlib", 62*3a22c0a3SAlix ], 63*3a22c0a3SAlix) 64*3a22c0a3SAlix 65*3a22c0a3SAlixkt_jvm_library( 66*3a22c0a3SAlix name = "car_demo_inline_lib", 67*3a22c0a3SAlix srcs = ["CarInlineDemo.kt"], 68*3a22c0a3SAlix tags = _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 69*3a22c0a3SAlix deps = [ 70*3a22c0a3SAlix "//tests/jvm/java/functions/car:car_inline_and_extra_lib_import", 71*3a22c0a3SAlix "//tests/jvm/java/functions/car:car_lib_import", 72*3a22c0a3SAlix ], 73*3a22c0a3SAlix) 74*3a22c0a3SAlix 75*3a22c0a3SAlix# This binary includes inline functions, imported from a jar file using kt_jvm_import. 76*3a22c0a3SAlix# Inlined functions cannot be imported using java_import, since ijar strips out functionality. 77*3a22c0a3SAlixjava_test( 78*3a22c0a3SAlix name = "car_inline_demo", 79*3a22c0a3SAlix main_class = "functions.CarInlineDemo", 80*3a22c0a3SAlix tags = ["darwin_x86_64_compatible"] + _NO_ZAPFHAHN_BECAUSE_LIBJARS_EXCLUDE_JACOCO, 81*3a22c0a3SAlix runtime_deps = [ 82*3a22c0a3SAlix ":car_demo_inline_lib", 83*3a22c0a3SAlix "@kotlinc//:kotlin_stdlib", 84*3a22c0a3SAlix ], 85*3a22c0a3SAlix) 86