bazelbuild / bazelbuild/rules_android

`rules_android_maven` Should Not Force Large Live Coursier Resolution

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

Description

## Summary

`rules_android@0.7.1` triggers large live Coursier resolution (no lock file), causing slow, fragile builds and frequent timeouts:

```
Error while fetching artifact with coursier: Timed out
```

## Repro

Repo: [https://github.com/bc-lee/rules-android-maven-live-resolution-repro](https://github.com/bc-lee/rules-android-maven-live-resolution-repro)

Run:
```bash
RJE_VERBOSE=true USE_BAZEL_VERSION=9.0.2 bazelisk build \
@rules_android//src/tools/java/com/google/devtools/build/android/r8:r8
```
(`RJE_VERBOSE=true` to expose Coursier behavior)

* [60be301](https://github.com/bc-lee/rules-android-maven-live-resolution-repro/commit/81604424109dfc93d5a23cd12b39cf788d2e6d5e): fails with timeout
* [c445ef1](https://github.com/bc-lee/rules-android-maven-live-resolution-repro/commit/c0554263d11558d2ad0232d914d8b255f26d5400): success with lock file

## Root Cause

`rules_android_maven` defines a large `maven.install(...)` (50+ artifacts) but does not enable its lock file, forcing:

* large live `coursier fetch`
* duplicate resolution (`rules_android_maven`, `bazel_worker_maven`)
* heavy network traffic before actual build

## Impact

* slow builds
* network-sensitive / flaky (timeouts)
* problematic in CI or restricted environments

## Suggested Fix

Enable the existing lock file:

```starlark
maven.install(
name = "rules_android_maven",
lock_file = "//:rules_android_maven_install.json",
...
)
```

## Evidence

With only this change:

```diff
- # lock_file = "//:rules_android_maven_install.json",
+ lock_file = "//:rules_android_maven_install.json",
```

the same build succeeds reliably.

## Workaround

Downstream patch:

```diff
+ lock_file = "//:rules_android_maven_install.json",
```

(Optionally `resolver = "gradle"`)

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.