xref: /aosp_15_r20/external/bazelbuild-rules_android/rules/aar_import/rule.bzl (revision 9e965d6fece27a77de5377433c2f7e6999b8cc0b)
1# Copyright 2018 The Bazel Authors. 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"""aar_import rule."""
16
17load(":attrs.bzl", _ATTRS = "ATTRS")
18load(":impl.bzl", _impl = "impl")
19
20RULE_DOC = """
21#### Examples
22
23The following example shows how to use `aar_import`.
24
25```starlark
26aar_import(
27    name = "hellobazellib",
28    aar = "lib.aar",
29    package = "bazel.hellobazellib",
30    deps = [
31        "//java/bazel/hellobazellib/activities",
32        "//java/bazel/hellobazellib/common",
33    ],
34)
35```
36"""
37
38def _impl_proxy(ctx):
39    providers, _ = _impl(ctx)
40    return providers
41
42aar_import = rule(
43    attrs = _ATTRS,
44    fragments = ["android"],
45    implementation = _impl_proxy,
46    doc = RULE_DOC,
47    provides = [
48        AndroidIdeInfo,
49        AndroidLibraryResourceClassJarProvider,
50        AndroidNativeLibsInfo,
51        JavaInfo,
52    ],
53    toolchains = [
54        "//toolchains/android:toolchain_type",
55        "@bazel_tools//tools/jdk:toolchain_type",
56    ],
57)
58