summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomain Jobredeaux <jobredeaux@google.com>2021-08-12 14:41:57 +0000
committerRomain Jobredeaux <jobredeaux@google.com>2021-08-12 14:46:21 +0000
commit4b40a09c583c4bd90e13b6eade9d80b85fe161da (patch)
treecbb3546d5c6eb60c2856d199f348b73c8b223fc0
parent49a4572303e4a218222f9fd70fc182b4e90d1f76 (diff)
downloadMusic-4b40a09c583c4bd90e13b6eade9d80b85fe161da.tar.gz
Declare resources in a library under kotlin/ for Music app Bazel build.
There is a bug where resources are not processed properly when declared from the top level directory. Test: b build packages/apps/Music Change-Id: Ib3126d7792cf38b0b2303bb5486f5b292b44889b
-rw-r--r--BUILD2
-rw-r--r--kotlin/BUILD31
2 files changed, 32 insertions, 1 deletions
diff --git a/BUILD b/BUILD
index 897af5c..bb1e5f0 100644
--- a/BUILD
+++ b/BUILD
@@ -5,5 +5,5 @@ android_binary(
srcs = glob(["src/**/*.java"]),
custom_package = "com.android.music",
manifest = "AndroidManifest.xml",
- resource_files = glob(["kotlin/res/**"]),
+ deps = ["//packages/apps/Music/kotlin:MusicResources"],
)
diff --git a/kotlin/BUILD b/kotlin/BUILD
new file mode 100644
index 0000000..ab0691c
--- /dev/null
+++ b/kotlin/BUILD
@@ -0,0 +1,31 @@
+load("@rules_android//rules:rules.bzl", "android_binary", "android_library")
+
+# Placeholder manifest is required to build the android library below.
+genrule(
+ name = "gen_placeholdermanifest",
+ outs = ["AndroidManifest.xml"],
+ cmd = """
+echo '<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.Music"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="21"
+ android:targetSdkVersion="21" />
+</manifest>
+
+' > $@""",
+)
+
+# Workaround a bug where including resources at the top-level android_binary fails,
+# it seems due to the resource folder being nested. Instead, we create this
+# library to hold the resources and make the android_binary target depend on it.
+android_library(
+ name = "MusicResources",
+ srcs = [],
+ custom_package = "com.android.music",
+ manifest = "AndroidManifest.xml",
+ resource_files = glob(["res/**"]),
+ visibility = ["//visibility:public"],
+)