forked from oppia/oppia-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
142 lines (130 loc) · 4.77 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# TODO(#1532): Rename file to 'BUILD' post-Gradle.
load("@dagger//:workspace_defs.bzl", "dagger_rules")
load("//:build_flavors.bzl", "AVAILABLE_FLAVORS", "define_oppia_aab_binary_flavor", "transform_android_manifest")
load("//:version.bzl", "MAJOR_VERSION", "MINOR_VERSION", "OPPIA_DEV_KITKAT_VERSION_CODE", "OPPIA_DEV_VERSION_CODE")
# This is exported here since config/ isn't a Bazel package.
exports_files(["config/kitkat_main_dex_class_list.txt"])
# Corresponds to being accessible to all Oppia targets. This should be used for production APIs &
# modules that may be used both in production targets and in tests.
package_group(
name = "oppia_api_visibility",
packages = [
"//...",
],
)
# Corresponds to being accessible to the Oppia binary. This should only be used by production-facing
# modules that must be included in the top-level binary in order for the app to build.
package_group(
name = "oppia_binary_visibility",
packages = [
"//",
],
)
# Corresponds to being accessible to Oppia tests. This should be used by fakes & test-only modules
# that can be included in tests for custom state arrangement or to satisfy upstream/downstream
# dependency requirements for components whose production implementations cannot be used in test
# environments.
# TODO(#2773): Remove the open visibility access granted here & instead restrict this access to only
# test targets.
package_group(
name = "oppia_testing_visibility",
packages = [
"//app/...",
"//data/...",
"//domain/...",
"//instrumentation/...",
"//testing/...",
"//utility/...",
],
)
package_group(
name = "oppia_e2e_testing_visibility",
packages = [
"//instrumentation/...",
],
)
# Special visibility group specific to debug mode. This provides access to the target for both the
# Oppia tests and specific debug only packages.
package_group(
name = "oppia_debug_visibility",
includes = [
":oppia_testing_visibility",
],
packages = [
"//app/src/main/java/org/oppia/android/app/devoptions/...",
],
)
# Special visibility group specific to prod modules. This provides access to the module for both the
# Oppia binary & tests.
package_group(
name = "oppia_prod_module_visibility",
includes = [
":oppia_binary_visibility",
":oppia_testing_visibility",
],
)
# TODO(#1640): Move binary manifest to top-level package post-Gradle.
[
transform_android_manifest(
name = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"],
application_relative_qualified_class = ".app.application.dev.DeveloperOppiaApplication",
build_flavor = apk_flavor_metadata["flavor"],
input_file = "//app:src/main/AndroidManifest.xml",
major_version = MAJOR_VERSION,
minor_version = MINOR_VERSION,
output_file = "AndroidManifest_transformed_%s.xml" % apk_flavor_metadata["flavor"],
version_code = apk_flavor_metadata["version_code"],
)
for apk_flavor_metadata in [
{
"flavor": "oppia",
"version_code": OPPIA_DEV_VERSION_CODE,
},
{
"flavor": "oppia_kitkat",
"version_code": OPPIA_DEV_KITKAT_VERSION_CODE,
},
]
]
[
android_binary(
name = apk_flavor_metadata["flavor"],
custom_package = "org.oppia.android",
enable_data_binding = True,
main_dex_list = apk_flavor_metadata.get("main_dex_list"),
manifest = "oppia_apk_%s_transformed_manifest" % apk_flavor_metadata["flavor"],
manifest_values = {
"applicationId": "org.oppia.android",
"minSdkVersion": "%d" % apk_flavor_metadata["min_sdk_version"],
"targetSdkVersion": "%d" % apk_flavor_metadata["target_sdk_version"],
},
multidex = apk_flavor_metadata["multidex"],
deps = [
"//app/src/main/java/org/oppia/android/app/application/dev:developer_application",
"//config/src/java/org/oppia/android/config:all_languages_config",
],
)
for apk_flavor_metadata in [
{
"flavor": "oppia",
"min_sdk_version": 21,
"multidex": "native",
"target_sdk_version": 33,
},
{
"flavor": "oppia_kitkat",
"main_dex_list": "//:config/kitkat_main_dex_class_list.txt",
"min_sdk_version": 21,
"multidex": "manual_main_dex",
"target_sdk_version": 33,
},
]
]
# Define all binary flavors that can be built. Note that these are AABs, not APKs, and can be
# be installed on a local device or emulator using a 'bazel run' command like so:
# bazel run //:install_oppia_dev
[
define_oppia_aab_binary_flavor(flavor = flavor)
for flavor in AVAILABLE_FLAVORS
]
dagger_rules()