Skip to content

Commit 8452f18

Browse files
Restore (limited) dynamic feature capability + introduce sample app
1 parent 4d719e1 commit 8452f18

32 files changed

+359
-14
lines changed

examples/bundle/.DS_Store

6 KB
Binary file not shown.

examples/bundle/.bazelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Flags needed while the Android rules are being migrated to Starlark.
2+
common --experimental_google_legacy_api
3+
common --experimental_enable_android_migration_apis
4+
common --android_sdk=@androidsdk//:sdk
5+
common:core_library_desugaring --desugar_java8_libs
6+
7+
# Flags to enable mobile-install v3
8+
mobile-install --mode=skylark --mobile_install_aspect=@rules_android//mobile_install:mi.bzl --mobile_install_supported_rules=android_binary
9+
# Required to invoke the Studio deployer jar
10+
mobile-install --tool_java_runtime_version=17

examples/bundle/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.lock

examples/bundle/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty build file to satisfy gazelle for rules_go.

examples/bundle/MODULE.bazel

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module(
2+
name = "bundle",
3+
)
4+
5+
bazel_dep(name = "rules_java", version = "7.4.0")
6+
bazel_dep(name = "bazel_skylib", version = "1.3.0")
7+
8+
bazel_dep(
9+
name = "rules_android",
10+
version = "0.5.1",
11+
)
12+
13+
local_path_override(
14+
module_name = "rules_android",
15+
path = "../../",
16+
)
17+
18+
remote_android_extensions = use_extension(
19+
"@rules_android//bzlmod_extensions:android_extensions.bzl",
20+
"remote_android_tools_extensions")
21+
use_repo(remote_android_extensions, "android_gmaven_r8", "android_tools")
22+
23+
register_toolchains(
24+
"@rules_android//toolchains/android:android_default_toolchain",
25+
"@rules_android//toolchains/android_sdk:android_sdk_tools",
26+
)
27+
28+
android_sdk_repository_extension = use_extension("@rules_android//rules/android_sdk_repository:rule.bzl", "android_sdk_repository_extension")
29+
use_repo(android_sdk_repository_extension, "androidsdk")
30+
31+
register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all")
32+
33+
bazel_dep(name = "rules_jvm_external", version = "5.3")
34+
35+
# Load the maven extension from rules_jvm_external
36+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
37+
38+
maven.install(
39+
name = "maven",
40+
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
41+
artifacts = [
42+
"com.google.guava:guava:32.1.2-android",
43+
"com.arthenica:ffmpeg-kit-https:4.4.LTS",
44+
],
45+
repositories = [
46+
"https://maven.google.com",
47+
"https://repo1.maven.org/maven2",
48+
],
49+
use_starlark_android_rules = True,
50+
)
51+
use_repo(maven, "maven")
52+
53+
54+
55+

examples/bundle/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To build, ensure that the `ANDROID_HOME` environment variable is set to the path
2+
to an Android SDK, and run:
3+
4+
```
5+
bazel build app:assets
6+
```
7+
8+
This will build application bundle containing a dynamic feature containing assets (named assets.txt). Verify with :
9+
10+
```
11+
jar -tf bazel-bin/app/assets_unsigned.aab | grep assets.txt
12+
```

examples/bundle/WORKSPACE

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
3+
4+
maybe(
5+
http_archive,
6+
name = "rules_jvm_external",
7+
strip_prefix = "rules_jvm_external-fa73b1a8e4846cee88240d0019b8f80d39feb1c3",
8+
sha256 = "7e13e48b50f9505e8a99cc5a16c557cbe826e9b68d733050cd1e318d69f94bb5",
9+
url = "https://github.com/bazelbuild/rules_jvm_external/archive/fa73b1a8e4846cee88240d0019b8f80d39feb1c3.zip",
10+
)
11+
12+
maybe(
13+
http_archive,
14+
name = "bazel_skylib",
15+
urls = [
16+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
17+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
18+
],
19+
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
20+
)
21+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
22+
bazel_skylib_workspace()
23+
24+
local_repository(
25+
name = "rules_android",
26+
path = "../..", # rules_android's WORKSPACE relative to this inner workspace
27+
)
28+
29+
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
30+
rules_android_prereqs()
31+
load("@rules_android//:defs.bzl", "rules_android_workspace")
32+
rules_android_workspace()
33+
34+
load("@rules_android//rules:rules.bzl", "android_sdk_repository")
35+
android_sdk_repository(
36+
name = "androidsdk",
37+
)
38+
39+
register_toolchains(
40+
"@rules_android//toolchains/android:android_default_toolchain",
41+
"@rules_android//toolchains/android_sdk:android_sdk_tools",
42+
)
43+
44+
load("@rules_jvm_external//:defs.bzl", "maven_install")
45+
46+
maven_install(
47+
name = "maven",
48+
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
49+
artifacts = [
50+
"com.google.guava:guava:32.1.2-android",
51+
"com.arthenica:ffmpeg-kit-https:4.4.LTS",
52+
],
53+
repositories = [
54+
"https://maven.google.com",
55+
"https://repo1.maven.org/maven2",
56+
],
57+
use_starlark_android_rules = True,
58+
)

examples/bundle/WORKSPACE.bzlmod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
workspace(name = "bundle")

examples/bundle/app/.DS_Store

6 KB
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.examples.bundle.app" >
4+
5+
<uses-sdk
6+
android:minSdkVersion="21"
7+
android:targetSdkVersion="30" />
8+
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@drawable/ic_launcher"
12+
android:label="@string/app_name" >
13+
<activity
14+
android:name="com.examples.bundle.app.BasicActivity"
15+
android:exported="true">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
<category android:name="android.intent.category.LAUNCHER" />
19+
</intent-filter>
20+
</activity>
21+
</application>
22+
</manifest>

0 commit comments

Comments
 (0)