Skip to content

Commit b5d5811

Browse files
committed
Run R8 on feature module
1 parent 8e1c0b9 commit b5d5811

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

examples/bundle/features/assets/BUILD

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ load("@rules_android//rules:rules.bzl", "android_feature_module")
44
android_library(
55
name = "lib",
66
srcs = ["src/FeatureActivity.java"],
7-
manifest = "src/AndroidManifest.xml",
87
assets = ["src/assets.txt"],
98
custom_package = "com.example.bundle.features.assets",
9+
manifest = "src/AndroidManifest.xml",
1010
)
1111

1212
android_feature_module(
1313
name = "feature_module",
1414
custom_package = "com.example.bundle.features.assets",
15-
manifest = "src/AndroidManifest.xml",
16-
title = "asset_feature",
17-
library = ":lib",
1815
feature_name = "asset_feature",
1916
has_dex = True,
17+
library = ":lib",
18+
manifest = "src/AndroidManifest.xml",
19+
proguard_specs = ["proguard-rules.pro"],
20+
title = "asset_feature",
2021
visibility = ["//visibility:public"],
21-
)
22+
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Proguard rules for dynamic feature module
2+
3+
# Keep the FeatureActivity class name for launching via Intent
4+
-keep class com.example.bundle.features.assets.FeatureActivity {
5+
<init>();
6+
}
7+
8+
# Obfuscate everything else
9+
-optimizationpasses 5
10+
-allowaccessmodification

rules/android_application/android_feature_module_rule.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ EOF
196196
"feature_flags": getattr(attrs, "feature_flags", None),
197197
"$enable_manifest_merging": False,
198198
"testonly": testonly,
199+
"proguard_specs": getattr(attrs, "proguard_specs", []),
199200
}
200201
_android_binary(**binary_attrs)
201202

rules/android_application/attrs.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ ANDROID_FEATURE_MODULE_ATTRS = dict(
124124
doc = "android_library target to include as a feature split.",
125125
),
126126
manifest = attr.label(allow_single_file = True),
127+
proguard_specs = attr.label_list(
128+
allow_empty = True,
129+
allow_files = True,
130+
doc = "Proguard specification files to apply to this feature module.",
131+
),
127132
title_id = attr.string(),
128133
title_lib = attr.string(),
129134
_feature_module_validation_script = attr.label(

0 commit comments

Comments
 (0)