xref: /aosp_15_r20/external/bazelbuild-kotlin-rules/tests/jvm/java/srcartifacts/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:rules.bzl", "kt_jvm_library", "kt_jvm_test")
16load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
17load("@bazel_skylib//rules:build_test.bzl", "build_test")
18
19package(
20    default_applicable_licenses = ["//:license"],
21    default_testonly = 1,
22)
23
24licenses(["notice"])
25
26kt_jvm_test(
27    name = "srcartifacts",
28    srcs = [
29        "JavaSrc.java",
30        "KtSrc.kt",
31        "SrcArtifactsTest.kt",
32        ":JavaSrcjar_gen",
33        ":dir/java",
34        ":dir/kotlin",
35    ],
36    resources = [
37        "dir/empty",
38        "dir/resources",
39    ],
40    test_class = "srcartifacts.SrcArtifactsTest",
41    deps = [
42        "@maven//:com_google_truth_truth",
43        "@maven//:junit_junit",
44    ],
45)
46
47kt_testing_rules.create_dir(
48    name = "dir/java",
49    srcs = [
50        "JavaInJavaDir.java",
51    ],
52    subdir = "srcartifacts",
53)
54
55kt_testing_rules.create_dir(
56    name = "dir/kotlin",
57    srcs = [
58        "KtInKotlinDir.kt",
59    ],
60    subdir = "srcartifacts",
61)
62
63kt_testing_rules.create_dir(
64    name = "dir/empty",
65    srcs = [],
66    subdir = "srcartifacts/empty",
67)
68
69kt_testing_rules.create_dir(
70    name = "dir/resources",
71    srcs = [
72        kt_testing_rules.create_file(
73            name = "resources_in_resources_dir.txt",
74            content = "Test resource content.",
75        ),
76    ],
77    subdir = "resources",
78)
79
80genrule(
81    name = "JavaSrcjar_gen",
82    srcs = [":libJavaSrcjar_lib-src.jar"],
83    outs = ["JavaSrcjar.srcjar"],
84    cmd = "cp $(location :libJavaSrcjar_lib-src.jar) $(location :JavaSrcjar.srcjar)",
85)
86
87java_library(
88    name = "JavaSrcjar_lib",
89    srcs = ["JavaSrcjar.java"],
90    tags = ["manual"],
91)
92
93kt_jvm_library(
94    name = "empty_java_tree_artifact",
95    srcs = [
96        kt_testing_rules.create_dir(
97            name = "dir/empty_java/java",
98            srcs = [],
99            subdir = "srcartifacts",
100        ),
101    ],
102)
103
104kt_jvm_library(
105    name = "empty_kotlin_tree_artifact",
106    srcs = [
107        kt_testing_rules.create_dir(
108            name = "dir/empty_kotlin/kotlin",
109            srcs = [],
110            subdir = "srcartifacts",
111        ),
112    ],
113)
114
115build_test(
116    name = "empty_dirs_build_test",
117    targets = [
118        "empty_java_tree_artifact",
119        "empty_kotlin_tree_artifact",
120    ],
121)
122