1# Copyright 2021 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"""android_application rule.
16
17This file exists to inject the correct version of android_binary.
18"""
19
20load(":android_application_rule.bzl", _android_application_macro = "android_application_macro")
21load("//rules:android_binary.bzl", _android_binary = "android_binary")
22
23def android_application(**attrs):
24    """Rule to build an Android Application (app bundle).
25
26    `android_application` produces an app bundle (.aab) rather than an apk, and treats splits
27    (both configuration and dynamic feature modules) as first-class constructs. If
28    `feature_modules`, `bundle_config` or both are supplied this rule will produce an .aab.
29    Otherwise it will fall back to `android_binary` and produce an apk.
30
31    **Attributes**
32
33    `android_application` accepts all the same attributes as `android_binary`, with the following
34    key differences.
35
36    Name | Description
37    --- | ---
38    `srcs` | `android_application` does not accept sources.
39    `manifest_values` | Required. Must specify `applicationId` in the `manifest_values`
40    `feature_modules` | New. List of labels to `android_feature_module`s to include as feature splits. Note: must be fully qualified paths (//some:target), not relative.
41    `bundle_config_file` | New. String path to .pb.json file containing the bundle config. See the [bundletool docs](https://developer.android.com/studio/build/building-cmdline#bundleconfig) for format and examples. Note: this attribute is subject to changes which may require teams to migrate their configurations to a build target.
42    `app_integrity_config` | Optional. String path to .binarypb file containing the play integrity config. See https://github.com/google/bundletool/blob/master/src/main/proto/app_integrity_config.proto.
43    `rotation_config` | Optional. String path to .textproto file containing the V3 rotation config.
44
45    Args:
46          **attrs: Rule attributes
47    """
48    _android_application_macro(
49        _android_binary = _android_binary,
50        **attrs
51    )
52