xref: /aosp_15_r20/build/bazel/rules/java/sdk_library.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2023 The Android Open Source Project
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
15JavaSdkLibraryInfo = provider(
16    "Checked in current.txt for Public, System, Module_lib and System_server",
17    fields = [
18        "public",
19        "system",
20        "test",
21        "module_lib",
22        "system_server",
23    ],
24)
25
26def _java_sdk_library_impl(ctx):
27    return [
28        JavaSdkLibraryInfo(
29            public = ctx.file.public,
30            system = ctx.file.system,
31            test = ctx.file.test,
32            module_lib = ctx.file.module_lib,
33            system_server = ctx.file.system_server,
34        ),
35    ]
36
37java_sdk_library = rule(
38    implementation = _java_sdk_library_impl,
39    attrs = {
40        "public": attr.label(
41            allow_single_file = True,
42            doc = "public api surface file",
43        ),
44        "system": attr.label(
45            allow_single_file = True,
46            doc = "system api surface file",
47        ),
48        "test": attr.label(
49            allow_single_file = True,
50            doc = "test api surface file",
51        ),
52        "module_lib": attr.label(
53            allow_single_file = True,
54            doc = "module_lib api surface file",
55        ),
56        "system_server": attr.label(
57            allow_single_file = True,
58            doc = "system_server api surface file",
59        ),
60    },
61)
62