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