bazelbuild / bazelbuild/bazel

Inefficient caching of Android binary artifacts Vs libraries/tests.

Open
#18,565 8 comments 1 reaction 0 assignees View on GitHub
P2 team-Android type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

TL;DR; In order to properly populate remote cache for developers, one has to build both android binaries and android/jvm libraries. This is costly and inefficient, as it requires double CI capacity/jobs. Can we please fix this?

When building android binaries, target platform is changed to android and artifacts are not shared when, let's say, a developer build the corresponding android library(ies) to run locally a unit test. In this case, the target platform is the local machine.
This means that, in order to have cache hits for both building project android binaries and project libraries/unit test/robolectric tests, we need to build both separately on CI. As these are not sharing output artifacts, jobs takes twice longer. Our CI cost essentially is doubled.

Fixing this means for most company significant $ savings. This problem is exacerbated by the fact we need to run build separately on both linux and mac.

### What underlying problem are you trying to solve with this feature?

Avoiding having to rebuild project twice on CI when populating remote cache for local devs.

### Which operating system are you running Bazel on?

Mac/Linux

### What is the output of `bazel info release`?

_No response_

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

Found an undocumented flag 'experimental_platform_in_output_dir' which could potentially help.

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by investigating the experimental_platform_in_output_dir flag and comparing remote-cache behavior for Android binaries versus JVM libraries and unit/Robolectric tests on Mac/Linux. A complete solution should avoid separate CI builds while preserving cache hits for both artifact types.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
build-system, ci-cd
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.