bazelbuild / bazelbuild/rules_android

Asset exclusion in android targets is broken when `--persistent_android_resource_processor` is enabled

Open
#310 3 comments 2 reactions 0 assignees View on GitHub
P2
Dominant language
Java
Stars
203
Forks
95
PR merge metrics
No merged PRs in 30d

Description

### Description of the problem / feature request:
In android targets, we should be able to exclude certain resources from root directory. Example
```
assets = glob(
["assets/**"],
exclude = [
"assets/abc.txt", "**/.DS_Store"
]
),
assets_dir = "assets",
```
However, when `--persistent_android_resource_processor` is enabled. The exclude will not work.

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I created a [test branch](https://github.com/ThomasCJY/bazel_example/tree/jchen-resPersistentWorkerExample/android_instrumentation_test) to repro this issue. You can easily follow the steps in readme to repro it.

### What operating system are you running Bazel on?
macos

### What's the output of `bazel info release`?
```
bazelisk version
Bazelisk version: v1.3.0
Build label: 4.2.1
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Aug 30 15:24:28 2021 (1630337068)
Build timestamp: 1630337068
Build timestamp as int: 1630337068
```

### Investigation
This bug is caused by [this line](https://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/main/java/com/google/devtools/build/lib/rules/android/AndroidResourceMergingActionBuilder.java#L130) where we only parse the root directory of the assets and send them as data params into resource busy box processor. Considering the fact that resource merger only takes directory as the param, I think a possible fix would be copy and paste valid assets to a temporary folder and use that directory as the input param in the resource merge action.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.